nyc
nyc copied to clipboard
nyc not working with mocha and ts-node
Link to bug demonstration repository
https://github.com/NikolayMakhonin/mocha-ts-nyc-error
Expected Behavior
Work without error and with correct paths to the files
Observed Behavior
Incorrect file paths and error:
C:\projects\mocha-ts-nyc-error\coverage\lcov-report\1\file:\C:\projects\mocha-ts-nyc-error\src\1
Troubleshooting steps
npm i
npm test
you should see this:
C:\projects\mocha-ts-nyc-error>npm test
> [email protected] test C:\projects\mocha-ts-nyc-error
> nyc --reporter lcov mocha -r ts-node/register ./src/qwe.test.ts
test
OK
OK
√ test
1 passing (7ms)
Path contains invalid characters: C:\projects\mocha-ts-nyc-error\coverage\lcov-report\1\file:\C:\projects\mocha-ts-nyc-error\src\1
ELIFECYCLE Test failed. See above for more details.
Environment Information
System:
OS: Windows 10 10.0.19042
CPU: (8) x64 Intel(R) Core(TM) i7-3610QM CPU @ 2.30GHz
Memory: 5.27 GB / 15.89 GB
Binaries:
Node: 14.19.3 - E:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.14.17 - E:\Program Files\nodejs\npm.CMD
npmPackages:
nyc: ^15.1.0 => 15.1.0
ts-node: ^10.8.1 => 10.8.1
typescript: ^4.7.4 => 4.7.4
This is caused by ts-node recent update. see https://github.com/TypeStrong/ts-node/pull/1771 as reported by https://github.com/TypeStrong/ts-node/issues/1790. Downgrade ts-node to 10.8.0 result the issue for me.
Yes, it working with [email protected], but not working with [email protected]
I just confirmed the fix in ts-node 10.8.2 resolves the issue for me.