Load EE fixtures from ee/ directory in Jest

(cherry picked from commit 2917a28a885922a03f2026ddbb2680bc2b6e5d50)
This commit is contained in:
Winnie Hellmann 2019-04-25 11:49:06 +02:00
parent 6e3165f0b4
commit fbac16b2de
2 changed files with 7 additions and 4 deletions

View file

@ -24,8 +24,9 @@ class CustomEnvironment extends JSDOMEnvironment {
});
const { testEnvironmentOptions } = config;
const { IS_EE } = testEnvironmentOptions;
this.global.gon = {
ee: testEnvironmentOptions.IS_EE,
ee: IS_EE,
};
this.rejectedPromises = [];
@ -33,6 +34,10 @@ class CustomEnvironment extends JSDOMEnvironment {
this.global.promiseRejectionHandler = error => {
this.rejectedPromises.push(error);
};
this.global.fixturesBasePath = `${process.cwd()}/${
IS_EE ? 'ee/' : ''
}spec/javascripts/fixtures`;
}
async teardown() {

View file

@ -3,10 +3,8 @@ import path from 'path';
import { ErrorWithStack } from 'jest-util';
const fixturesBasePath = path.join(process.cwd(), 'spec', 'javascripts', 'fixtures');
export function getFixture(relativePath) {
const absolutePath = path.join(fixturesBasePath, relativePath);
const absolutePath = path.join(global.fixturesBasePath, relativePath);
if (!fs.existsSync(absolutePath)) {
throw new ErrorWithStack(
`Fixture file ${relativePath} does not exist.