diff options
author | Winnie Hellmann <winnie@gitlab.com> | 2019-03-27 14:55:40 +0100 |
---|---|---|
committer | Winnie Hellmann <winnie@gitlab.com> | 2019-03-29 07:33:30 +0100 |
commit | b0e26ed5cedc9452b63616a58d52c404ff5b5c98 (patch) | |
tree | 55b1475a12b7f60c668e6f6234a3afe10dfd99b8 /spec | |
parent | 9c2237569d9ff9dcca8182de794506b5500ef024 (diff) | |
download | gitlab-ce-b0e26ed5cedc9452b63616a58d52c404ff5b5c98.tar.gz |
Add Karma-style fixture helpers to Jestwinh-jest-html-fixtures
Diffstat (limited to 'spec')
-rw-r--r-- | spec/frontend/.eslintrc.yml | 9 | ||||
-rw-r--r-- | spec/frontend/environment.js | 1 | ||||
-rw-r--r-- | spec/frontend/test_setup.js | 9 |
3 files changed, 17 insertions, 2 deletions
diff --git a/spec/frontend/.eslintrc.yml b/spec/frontend/.eslintrc.yml index 046215e4c93..054dc27cda6 100644 --- a/spec/frontend/.eslintrc.yml +++ b/spec/frontend/.eslintrc.yml @@ -2,8 +2,13 @@ env: jest/globals: true plugins: -- jest + - jest settings: import/resolver: jest: - jestConfigFile: "jest.config.js" + jestConfigFile: 'jest.config.js' +globals: + getJSONFixture: false + loadFixtures: false + preloadFixtures: false + setFixtures: false diff --git a/spec/frontend/environment.js b/spec/frontend/environment.js index cb128c7d880..d38f8f3bac3 100644 --- a/spec/frontend/environment.js +++ b/spec/frontend/environment.js @@ -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( diff --git a/spec/frontend/test_setup.js b/spec/frontend/test_setup.js index 1edb2450b4c..2986e5d6f86 100644 --- a/spec/frontend/test_setup.js +++ b/spec/frontend/test_setup.js @@ -2,6 +2,7 @@ import Vue from 'vue'; import Translate from '~/vue_shared/translate'; import axios from '~/lib/utils/axios_utils'; import { initializeTestTimeout } from './helpers/timeout'; +import { getJSONFixture, loadHTMLFixture, setHTMLFixture } from './helpers/fixtures'; // wait for pending setTimeout()s afterEach(() => { @@ -32,3 +33,11 @@ Object.defineProperty(global.Element.prototype, 'innerText', { }, configurable: true, // make it so that it doesn't blow chunks on re-running tests with things like --watch }); + +// convenience wrapper for migration from Karma +Object.assign(global, { + loadFixtures: loadHTMLFixture, + loadJSONFixtures: getJSONFixture, + preloadFixtures() {}, + setFixtures: setHTMLFixture, +}); |