Closed
Description
Details
Just FYI, testing works fine when using the following:
node --import tsx --test test/myfile.ts
Problem 1
When trying to use code coverage with node --import tsx --experimental-test-coverage --test test/myfile.ts
I get the following warning (and no code coverage):
ℹ Warning: Could not report code coverage. TypeError: Cannot read properties of undefined (reading 'line')
What can I do to get code coverage?
Problem 2
Whenever I spy in the ts file, intellisense gives warnings about type missing for mock. Eg:
t.mock.method(serverFromOtherTsFile, "myMockedMethod");
assert.strictEqual(serverFromOtherTsFile.myMockedMethod.mock.calls.length, 0);
await serverFromOtherTsFile.myMockedMethod();
assert.strictEqual(serverFromOtherTsFile.myMockedMethod.mock.calls.length, 1);
The mock
property doesn't exist on type myMockedMethod. How can I type this? For clarity, the tests still run, it's just in VSCode I get the warnings as mock doesn't exist on myMockedMethod.
Thanks for your help
Node.js version
v20.10.0
Example code
No response
Operating system
macOS
Scope
code / runtime
Module and version
Not applicable.