Describe the bug
Example:
import { test, vi } from "vitest"
const cli = {
waitForOutput: vi.defineHelper(async () => {
throw new Error('foo')
})
}
test('bad', async () => {
await cli.waitForOutput()
});
test('good', async () => {
const { waitForOutput } = cli
await waitForOutput()
});
❯ test/repro.test.ts (2 tests | 2 failed) 3ms
× bad 1ms
× good 1ms
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Failed Tests 2 ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
FAIL test/repro.test.ts:9:1 > bad
Error: foo
❯ test/repro.test.ts:5:11
3| const cli = {
4| waitForOutput: vi.defineHelper(async () => {
5| throw new Error('foo')
| ^
6| })
7| }
❯ test/repro.test.ts:10:13
❯ new Promise ../../../blitz.4c73681d.js:31:30606
❯ new Promise ../../../blitz.4c73681d.js:31:30606
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/2]⎯
FAIL test/repro.test.ts:13:1 > good
Error: foo
❯ test/repro.test.ts:15:9
13| test('good', async () => {
14| const { waitForOutput } = cli
15| await waitForOutput()
| ^
16| });
17|
❯ new Promise ../../../blitz.4c73681d.js:31:30606
❯ new Promise ../../../blitz.4c73681d.js:31:30606
I've tested with the PR #10127 and it doesn't seem to fix, so likely this is a different issue about stack method naming.
Side note: I was tinkering to dog-food vi.defineHelper in our test utils, but apparently this doesn't yet work as is.
|
private waitForOutput(expected: string, source: Source, caller: Parameters<typeof Error.captureStackTrace>[1]) { |
|
const error = new Error('Timeout') |
|
Error.captureStackTrace(error, caller) |
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-ew6hi9an?file=test%2Frepro.test.ts
System Info
Used Package Manager
npm
Validations
Describe the bug
Example:
I've tested with the PR #10127 and it doesn't seem to fix, so likely this is a different issue about stack method naming.
Side note: I was tinkering to dog-food
vi.defineHelperin our test utils, but apparently this doesn't yet work as is.vitest/test/test-utils/cli.ts
Lines 72 to 74 in 1413382
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-ew6hi9an?file=test%2Frepro.test.ts
System Info
Used Package Manager
npm
Validations