gitlab-org--gitlab-foss/spec/frontend/environment.js

34 lines
819 B
JavaScript
Raw Normal View History

/* eslint-disable import/no-commonjs */
const { ErrorWithStack } = require('jest-util');
const JSDOMEnvironment = require('jest-environment-jsdom');
class CustomEnvironment extends JSDOMEnvironment {
constructor(config, context) {
super(config, context);
2019-03-28 12:38:29 +00:00
Object.assign(context.console, {
error(...args) {
throw new ErrorWithStack(
`Unexpected call of console.error() with:\n\n${args.join(', ')}`,
this.error,
);
},
warn(...args) {
throw new ErrorWithStack(
`Unexpected call of console.warn() with:\n\n${args.join(', ')}`,
this.warn,
);
},
});
2019-03-28 12:38:29 +00:00
const { testEnvironmentOptions } = config;
this.global.gon = {
ee: testEnvironmentOptions.IS_EE,
};
}
}
module.exports = CustomEnvironment;