summaryrefslogtreecommitdiff
path: root/spec/frontend/environment.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/environment.js')
-rw-r--r--spec/frontend/environment.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/spec/frontend/environment.js b/spec/frontend/environment.js
new file mode 100644
index 00000000000..1067a53906a
--- /dev/null
+++ b/spec/frontend/environment.js
@@ -0,0 +1,33 @@
+/* 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);
+
+ 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,
+ );
+ },
+ });
+
+ const { testEnvironmentOptions } = config;
+ this.global.gon = {
+ ee: testEnvironmentOptions.IS_EE,
+ };
+ }
+}
+
+module.exports = CustomEnvironment;