Skip to content

Commit

Permalink
Add yarn to run jest command (#3735)
Browse files Browse the repository at this point in the history
This PR makes the following changes:
- Changes the `runJest` script to call `yarn` with `jest` as the first
argument rather than calling `jest` on its own. This allows the test
runner to run tests in a package using `yarn3 PnP` and ESM modules
without getting module not found errors.
- Bump scripts from 1.0.0 to 1.0.1
  • Loading branch information
busma13 authored Aug 29, 2024
1 parent e2d2e18 commit ff0485d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@terascope/scripts",
"displayName": "Scripts",
"version": "1.0.0",
"version": "1.0.1",
"description": "A collection of terascope monorepo scripts",
"homepage": "https://github.com/terascope/teraslice/tree/master/packages/scripts#readme",
"bugs": {
Expand Down
8 changes: 6 additions & 2 deletions packages/scripts/src/helpers/scripts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,11 @@ export async function runJest(
extraArgs?: string[],
debug?: boolean
): Promise<void> {
const args = mapToArgs(argsMap);
// When running jest in yarn3 PnP with ESM we must call 'yarn jest <...args>'
// to prevent module not found errors. Therefore we will call fork with the yarn
// command and set jest to the first argument.
const args = ['jest'];
args.push(...mapToArgs(argsMap));
if (extraArgs) {
extraArgs.forEach((extraArg) => {
if (extraArg.startsWith('-') && args.includes(extraArg)) {
Expand All @@ -168,7 +172,7 @@ export async function runJest(
}

await fork({
cmd: 'jest',
cmd: 'yarn',
cwd,
args,
env,
Expand Down

0 comments on commit ff0485d

Please sign in to comment.