double hyphen not working for pnpm version >=7
vlkerag opened this issue · 2 comments
Discussed in #406
Originally posted by vlkerag January 19, 2024
The double hyphen appears to not be working for pnpm >=7
const isNpmStyle = command.startsWith('npm') || command.startsWith('pnpm');
command,
// add two hypens if it is npm or pnpm package managers and two hyphens don't already exist
isNpmStyle && !hasDoubleHyphen && '--',
Version <7 is working fine:
pnpm --version
6.2.1
pnpm test:unit -- --ci --json --coverage --testLocationInResults --outputFile=report.json
...
Test Suites: 16 passed, 16 total
Tests: 328 passed, 328 total
Snapshots: 4 passed, 4 total
Time: 7.577 s
Ran all test suites.
Test results written to: report.json
Version >=7 is not detecting tests with the double hyphens:
pnpm --version
7.2.1
pnpm test:unit -- --ci --json --coverage --testLocationInResults --outputFile=report.json
No tests found, exiting with code 1
Version >=7 is working fine when removing the double hyphens:
pnpm --version
7.2.1
pnpm test:unit --ci --json --coverage --testLocationInResults --outputFile=report.json
...
Test Suites: 16 passed, 16 total
Tests: 328 passed, 328 total
Snapshots: 4 passed, 4 total
Time: 9.823 s
Ran all test suites.
Test results written to: report.json
It seems that pnpm v7 doesn't use --
anymore.
Even though their PR is stating that it's backward compatible, it's not working with jest.
I am using pnpm v7 in a project too, and this caused a problem in an action I was working in.
Edit:
In case it helps someone, you can overwrite the default args by using the same args it automatically inserts in the test-script
field, like this:
test-script: pnpm test:unit --ci --json --coverage --testLocationInResults --outputFile=report.json
This will work using pnpm v7 and might be a workaround until the code is compatible with pnpm v7.