Describe the bug
Given a test like
it('should fail at the second expect', () => {
expect(1).to.equal(1);
expect(2).to.equal(1);
});
you get the expect output, e.g.
FAIL my/test/selection.test.ts > selection > single > should fail at the second expect
AssertionError: expected 2 to equal 1
- Expected
+ Received
- 1
+ 2
❯ my/test/selection.test.ts:123:19
121| it('should fail at the second expect', () => {
122| expect(1).to.equal(1);
123| expect(2).to.equal(1);
| ^
124| });
125| });
But when expect is extracted to a helper like
function e(a: number, b: number) {
expect(a).to.equal(b);
}
the output of the test
it('should fail at the second expect', () => {
e(1, 1);
e(2, 1);
});
is
FAIL my/test/selection.test.ts > selection > single > should fail at the second expect
AssertionError: expected 2 to equal 1
- Expected
+ Received
- 1
+ 2
❯ e my/test/selection.test.ts:80:17
78|
79| function e(a: number, b: number) {
80| expect(a).to.equal(b);
| ^
81| }
82|
❯ my/test/selection.test.ts:123:6
and actually I did not realize before pasting the error here that the line number is actually present for the test case (my/test/selection.test.ts:123:6). I thought it was completely missing. Could maybe the line of the actual test always be printed?
Reproduction
As above
System Info
System:
OS: macOS 14.0
CPU: (10) arm64 Apple M1 Max
Memory: 870.36 MB / 64.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm
bun: 1.0.7 - ~/.bun/bin/bun
Browsers:
Brave Browser: 107.1.45.123
Chrome: 119.0.6045.123
Chrome Canary: 121.0.6125.0
Edge: 119.0.2151.58
Safari: 17.0
npmPackages:
@vitejs/plugin-react: 4.1.1 => 4.1.1
@vitest/browser: ^0.34.6 => 0.34.6
@vitest/ui: ^0.34.6 => 0.34.6
vite: 4.5.0 => 4.5.0
vitest: ^0.34.6 => 0.34.6
Used Package Manager
npm
Validations
Describe the bug
Given a test like
you get the expect output, e.g.
But when
expectis extracted to a helper likethe output of the test
is
and actually I did not realize before pasting the error here that the line number is actually present for the test case (
my/test/selection.test.ts:123:6). I thought it was completely missing. Could maybe the line of the actual test always be printed?Reproduction
As above
System Info
System: OS: macOS 14.0 CPU: (10) arm64 Apple M1 Max Memory: 870.36 MB / 64.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm bun: 1.0.7 - ~/.bun/bin/bun Browsers: Brave Browser: 107.1.45.123 Chrome: 119.0.6045.123 Chrome Canary: 121.0.6125.0 Edge: 119.0.2151.58 Safari: 17.0 npmPackages: @vitejs/plugin-react: 4.1.1 => 4.1.1 @vitest/browser: ^0.34.6 => 0.34.6 @vitest/ui: ^0.34.6 => 0.34.6 vite: 4.5.0 => 4.5.0 vitest: ^0.34.6 => 0.34.6Used Package Manager
npm
Validations