Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: handle mismatch between circus and runtime versions #9903

Merged
merged 2 commits into from Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
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
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);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for posterity, I didn't bother guarding this as esm will be falsy if the function doesn't exist

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
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
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
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