Skip to content

Commit

Permalink
fix: error when debugging in IntelliJ
Browse files Browse the repository at this point in the history
  • Loading branch information
noomorph committed Oct 11, 2023
1 parent 4e45e5f commit 4b07096
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion e2e/jest-recorder.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const presets = {
},
'no-reporter-1': {
...mixins.env(true),
...mixins.workers(2),
...mixins.workers(1),
reporters: ['default'],
},
'no-reporter-N': {
Expand Down
29 changes: 17 additions & 12 deletions src/environment-hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,28 @@ export function onTestEnvironmentCreate(
realm.events.add(realm.setEmitter);

if (!realm.globalMetadata.hasTestFileMetadata(testFilePath)) {
if (realm.type === 'child_process') {
realm.coreEmitter.emit({
type: 'add_test_file',
testFilePath,
});
} else {
realm.coreEmitter.emit({
type: 'add_test_file',
testFilePath,
});

if (realm.type === 'parent_process') {
const { globalConfig } = jestEnvironmentConfig;
const first = <T>(r: T[]) => r[0];
const hint = globalConfig?.reporters
? ` "reporters": ${inspect(globalConfig.reporters.map(first))}\n`
const hint = globalConfig
? ` "reporters": ${inspect(globalConfig.reporters?.map(first))}\n`
: ''; // Jest 27 fallback

throw new JestMetadataError(
const message =
`Cannot use a metadata test environment without a metadata server.\n` +
`Please check that at least one of the reporters in your Jest config inherits from "jest-metadata/reporter".\n` +
hint,
);
`Please check that at least one of the reporters in your Jest config inherits from "jest-metadata/reporter".\n` +
hint;

if (globalConfig && (globalConfig.runInBand || globalConfig.maxWorkers === 1)) {
console.warn('[jest-metadata] ' + message);
} else {
throw new JestMetadataError(message);
}
}
}

Expand Down

0 comments on commit 4b07096

Please sign in to comment.