-
-
Notifications
You must be signed in to change notification settings - Fork 33.2k
Closed
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.source mapsIssues and PRs related to source map support.Issues and PRs related to source map support.
Description
Version
v23.11.0
Platform
Darwin Kernel Version 24.4.0 (ARM) but likely not relevant
Subsystem
test_runner
What steps will reproduce the bug?
Create the 3 below files in a folder and run node --experimental-transform-types --experimental-test-module-mocks --test --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout ./foo.test.mts
files
bar.mts
export default function bar() {
return 'original bar';
}
foo.mts
import bar from './bar.mts';
export const foo = () => bar();
foo.test.mts
import assert from 'node:assert/strict';
import { before, describe, it, mock } from 'node:test';
describe('foo', { concurrency: true }, () => {
let barMock = mock.fn();
let foo;
before(async () => {
const barNamedExports = await import('./bar.mts')
.then(({ default: _, ...rest }) => rest);
mock.module('./bar.mts', {
defaultExport: barMock,
namedExports: barNamedExports,
});
({ foo } = await import('./foo.mts'));
});
it('should do the thing', () => {
barMock.mock.mockImplementationOnce(() => 42);
assert.equal(foo(), 42);
});
});
How often does it reproduce? Is there a required condition?
always
What is the expected behavior? Why is that the expected behavior?
tests pass and test coverage is displayed
What do you see instead?
tests pass but test coverage failed:
(node:49928) ExperimentalWarning: Type Stripping is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:49928) ExperimentalWarning: Module mocking is an experimental feature and might change at any time
▶ foo
✔ should do the thing (0.46475ms)
✔ foo (36.605917ms)
ℹ Warning: Could not report code coverage. TypeError: Cannot read properties of undefined (reading 'startOffset')
ℹ tests 1
ℹ suites 1
ℹ pass 1
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 155.707375
Additional information
looks similar to #55054
pmarchini
Metadata
Metadata
Assignees
Labels
confirmed-bugIssues with confirmed bugs.Issues with confirmed bugs.source mapsIssues and PRs related to source map support.Issues and PRs related to source map support.