Closed
Description
Describe the bug
When running tests that encounter an error in a required file, the generated trace does not point to the correct file.
Expected:
ReferenceError: boop is not defined
❯ test/main.test.js:5:12
> src/main.js:2:9
1| export function testFunc(x) {
2| return boop(x);
| ^
3| }
Actual:
ReferenceError: boop is not defined
❯ Module.testFunc ../../../../../src/main.js:2:3
❯ test/main.test.js:5:12
3| describe('Main test', () => {
4| it('should blow up here', () => {
5| expect(testFunc(5)).toBe(10);
| ^
6| });
7| });
Reproduction
- Check out https://github.com/DanHulton/vitest-stack-sourcemap-repro
yarn install
yarn test
System Info
System:
OS: macOS 13.2.1
CPU: (8) x64 Apple M1 Pro
Memory: 19.44 MB / 32.00 GB
Shell: 3.5.1 - /usr/local/bin/fish
Binaries:
Node: 17.3.0 - /usr/local/bin/node
Yarn: 3.3.1 - /usr/local/bin/yarn
npm: 8.16.0 - /usr/local/bin/npm
Browsers:
Chrome: 110.0.5481.177
Firefox: 109.0
Safari: 16.3
npmPackages:
vite: latest => 4.1.4
vitest: latest => 0.29.2
Used Package Manager
yarn
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.