Ghost/ghost/core/test/utils/overrides.js
Simon Backx f50224f445
Improved network access and mocking in tests (#16371)
refs https://github.com/TryGhost/Team/issues/2667

Some tests still accessed the internet. Now network access is disabled
by default. This change also introduces two helper methods related to
networking (mocking Slack and Mailgun).

This fixes two unreliable tests:
- Staff service was accessing a Slack test API -> timeout possible
- MentionSendingService was trying to send webmentions for every post
publish/change -> possible timeouts and job issues
2023-03-07 13:20:28 +01:00

20 lines
616 B
JavaScript

process.env.NODE_ENV = process.env.NODE_ENV || 'testing';
process.env.WEBHOOK_SECRET = process.env.WEBHOOK_SECRET || 'TEST_STRIPE_WEBHOOK_SECRET';
require('../../core/server/overrides');
const {mochaHooks} = require('@tryghost/express-test').snapshot;
exports.mochaHooks = mochaHooks;
const mockManager = require('./e2e-framework-mock-manager');
const originalBeforeAll = mochaHooks.beforeAll;
mochaHooks.beforeAll = async function () {
if (originalBeforeAll) {
await originalBeforeAll();
}
// Disable network in tests to prevent any accidental requests
mockManager.disableNetwork();
};