提交 63f6fcd0 编写于 作者: W Winnie Hellmann

Set gon.ee in Jest

上级 5a2d7bf2
const fs = require('fs');
const path = require('path');
const ROOT_PATH = __dirname;
const IS_EE =
process.env.EE !== undefined
? JSON.parse(process.env.EE)
: fs.existsSync(path.join(ROOT_PATH, 'ee'));
const IS_EE = require('./config/helpers/is_ee_env');
const reporters = ['default'];
......@@ -46,4 +38,7 @@ module.exports = {
transformIgnorePatterns: ['node_modules/(?!(@gitlab/ui)/)'],
timers: 'fake',
testEnvironment: '<rootDir>/spec/frontend/environment.js',
testEnvironmentOptions: {
IS_EE,
},
};
......@@ -6,6 +6,7 @@ const JSDOMEnvironment = require('jest-environment-jsdom');
class CustomEnvironment extends JSDOMEnvironment {
constructor(config, context) {
super(config, context);
Object.assign(context.console, {
error(...args) {
throw new ErrorWithStack(
......@@ -21,6 +22,11 @@ class CustomEnvironment extends JSDOMEnvironment {
);
},
});
const { testEnvironmentOptions } = config;
this.global.gon = {
ee: testEnvironmentOptions.IS_EE,
};
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册