Skip to content

Commit

Permalink
fix: handle mismatch between circus and runtime versions (#9903)
Browse files Browse the repository at this point in the history
* fix: handle mismatch between circus and runtime versions

* changelog
  • Loading branch information
SimenB authored Apr 28, 2020
1 parent ac267b1 commit 80dde6f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Fixes

- `[expect]` Prints the Symbol name into the error message with a custom asymmetric matcher ([#9888](https://github.com/facebook/jest/pull/9888))
- `[jest-circus, jest-jasmine2]` Support older version of `jest-runtime` ([#9903](https://github.com/facebook/jest/pull/9903) & [#9842](https://github.com/facebook/jest/pull/9842))
- `[@jest/environment]` Make sure not to reference Jest types ([#9875](https://github.com/facebook/jest/pull/9875))
- `[jest-message-util]` Code frame printing should respect `--noStackTrace` flag ([#9866](https://github.com/facebook/jest/pull/9866))
- `[jest-runtime]` Support importing CJS from ESM using `import` statements ([#9850](https://github.com/facebook/jest/pull/9850))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ const jestAdapter = async (
});

for (const path of config.setupFilesAfterEnv) {
const esm = runtime.unstable_shouldLoadAsEsm(path);
// TODO: remove ? in Jest 26
const esm = runtime.unstable_shouldLoadAsEsm?.(path);

if (esm) {
await runtime.unstable_importModule(path);
Expand All @@ -86,7 +87,8 @@ const jestAdapter = async (
}
}

const esm = runtime.unstable_shouldLoadAsEsm(testPath);
// TODO: remove ? in Jest 26
const esm = runtime.unstable_shouldLoadAsEsm?.(testPath);

if (esm) {
await runtime.unstable_importModule(testPath);
Expand Down
6 changes: 4 additions & 2 deletions packages/jest-jasmine2/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ async function jasmine2(
});

for (const path of config.setupFilesAfterEnv) {
const esm = runtime.unstable_shouldLoadAsEsm(path);
// TODO: remove ? in Jest 26
const esm = runtime.unstable_shouldLoadAsEsm?.(path);

if (esm) {
await runtime.unstable_importModule(path);
Expand All @@ -177,7 +178,8 @@ async function jasmine2(
env.specFilter = (spec: Spec) => testNameRegex.test(spec.getFullName());
}

const esm = runtime.unstable_shouldLoadAsEsm(testPath);
// TODO: remove ? in Jest 26
const esm = runtime.unstable_shouldLoadAsEsm?.(testPath);

if (esm) {
await runtime.unstable_importModule(testPath);
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-runner/src/runTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ async function runTestInternal(
const start = Date.now();

for (const path of config.setupFiles) {
const esm = runtime.unstable_shouldLoadAsEsm(path);
// TODO: remove ? in Jest 26
const esm = runtime.unstable_shouldLoadAsEsm?.(path);

if (esm) {
await runtime.unstable_importModule(path);
Expand Down
6 changes: 4 additions & 2 deletions packages/jest-runtime/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,17 @@ export async function run(
const runtime = new Runtime(config, environment, hasteMap.resolver);

for (const path of config.setupFiles) {
const esm = runtime.unstable_shouldLoadAsEsm(path);
// TODO: remove ? in Jest 26
const esm = runtime.unstable_shouldLoadAsEsm?.(path);

if (esm) {
await runtime.unstable_importModule(path);
} else {
runtime.requireModule(path);
}
}
const esm = runtime.unstable_shouldLoadAsEsm(filePath);
// TODO: remove ? in Jest 26
const esm = runtime.unstable_shouldLoadAsEsm?.(filePath);

if (esm) {
await runtime.unstable_importModule(filePath);
Expand Down

0 comments on commit 80dde6f

Please sign in to comment.