Add Karma-style fixture helpers to Jest
This commit is contained in:
parent
9c2237569d
commit
b0e26ed5ce
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue