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: use import instead of require when loading runner #148

Merged
merged 1 commit into from
Sep 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/createJestRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,16 @@ export default function createRunner<
);
}

_createInBandTestRun(
async _createInBandTestRun(
tests: Array<Test>,
watcher: TestWatcher,
onStart: OnTestStart,
onResult: OnTestSuccess,
onFailure: OnTestFailure,
options: TestRunnerOptions,
): Promise<void> {
const runner = (await import(runPath)).default;
Copy link
Contributor

Choose a reason for hiding this comment

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

Hm.. I still see require in the lates version. Is this because of Babel:

const runner = (await Promise.resolve(`${runPath}`).then(s => _interopRequireWildcard(require(s)))).default;

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch 👍


const mutex = pLimit(1);
return tests.reduce(
(promise, test) =>
Expand All @@ -87,8 +89,6 @@ export default function createRunner<
}

return onStart(test).then(() => {
// eslint-disable-next-line import/no-dynamic-require, global-require, @typescript-eslint/no-var-requires
const runner = require(runPath);
const baseOptions = {
config: test.context.config,
globalConfig: this.#globalConfig,
Expand Down