Jest line numbers are wrong
plaa opened this issue · 1 comments
plaa commented
If you add a failing test to add.test.ts
:
describe('boom', () => {
it('should boom', () => {
expect('boom').toEqual('baam')
})
})
it produces completely wrong line numbers. The failing expect is on line 11, but the output reports line 27:
● boom › should boom
expect(received).toEqual(expected) // deep equality
Expected: "baam"
Received: "boom"
at Object.<anonymous> (src/lib/add.test.ts:27:20)
After several hours of debugging / googling I haven't been able to figure out what's wrong in the configuration or how to fix this. Do you have any idea how to fix the line numbers?
tonykaram1993 commented
I have tried your exact failing test and got the following output and everything looks fine to me:
• Running test in 5 packages
server:test: cache miss, executing 7cfd04e85237fbac
server:build: cache miss, executing 43333453098f3609
server:build: yarn run v1.22.18
server:test: yarn run v1.22.18
server:build: $ tsc
server:test: $ jest --coverage
server:build: Done in 1.08s.
next-app:test: cache miss, executing 39237aee29660787
next-app:test: yarn run v1.22.18
next-app:test: $ jest --coverage
server:test: -------------------|---------|----------|---------|---------|-------------------
server:test: File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
server:test: -------------------|---------|----------|---------|---------|-------------------
server:test: All files | 0 | 0 | 0 | 0 |
server:test: expect(received).toEqual(expected) // deep equality
server:test: Expected: "baam"
server:test: Received: "boom"
server:test: 1 | describe('boom', () => {
server:test: 2 | it('should boom', () => {
server:test: > 3 | expect('boom').toEqual('baam');
server:test: | ^
server:test: 4 | });
server:test: 5 | });
server:test: 6 |
server:test: at Object.<anonymous> (src/lib/add.test.ts:3:20)
server:test: Test Suites: 1 failed, 1 total
server:test: Tests: 1 failed, 1 total
server:test: Snapshots: 0 total
server:test: Time: 0.787 s, estimated 1 s
server:test: Ran all test suites.
server:test: error Command failed with exit code 1.
server:test: Error: command finished with error: exit status 1
husky - pre-commit hook exited with code 1 (error)
This is my add.test.ts
file for reference:
describe('boom', () => {
it('should boom', () => {
expect('boom').toEqual('baam');
});
});