You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently when the hook times out, Vitest only shows the fact that the run failed with Hook time out.
FAIL test/basic.test.ts [ test/basic.test.ts ]
Error: Hook timed out in 1000ms.
If this is a long-running hook, pass a timeout value as the last argument or configure it globally with "hookTimeout".
With this error, it is difficult to know which hook timed out.
Suggested solution
Improve the error message to show the place where the hook exists like when the test failed.
FAIL test/basic.test.ts
Error: Hook timed out in 1000ms.
If this is a long-running hook, pass a timeout value as the last argument or configure it globally with "hookTimeout".
❯ test/basic.test.ts:10:1
9|
10| beforeAll(() => {
| ^
11| return new Promise((resolve) => {});
12| });
13|
I guess this is possible by adding new Error().stack / Error.captureStackTrace() here and passing that information to withTimeout.
FAIL test/basic.test.ts [ test/basic.test.ts ]
Error: Hook "myHook" timed out in 1000ms.
If this is a long-running hook, pass a timeout value as the last argument or configure it globally with "hookTimeout".
This is possible by passing fn.name to makeTimeoutMsg here.
Sorry to comment on a closed issue, but I just wanted to make sure I understand the feature before opening a new one.
I updated to vitest 3.0.9 and I see no difference in my logs when a hook times out - is there any place where this feature must be enabled? I couldn't find any indication of it in the linked PR.
Sorry to comment on a closed issue, but I just wanted to make sure I understand the feature before opening a new one.
I updated to vitest 3.0.9 and I see no difference in my logs when a hook times out - is there any place where this feature must be enabled? I couldn't find any indication of it in the linked PR.
If you have problems, open a new issue with a reproduction. Everything should work with 3.0.9.
Clear and concise description of the problem
Currently when the hook times out, Vitest only shows the fact that the run failed with Hook time out.
Example fail: https://stackblitz.com/edit/vitest-dev-vitest-qgnj5ff5?file=test%2Fbasic.test.ts&initialPath=__vitest__/
With this error, it is difficult to know which hook timed out.
Suggested solution
Improve the error message to show the place where the hook exists like when the test failed.
I guess this is possible by adding
new Error().stack
/Error.captureStackTrace()
here and passing that information towithTimeout
.vitest/packages/runner/src/hooks.ts
Line 39 in 926ca95
Although, creating stacktrace for every hook might affect performance.
Alternative
Show the function name passed to the hook in the error message.
For the code above, the error message will be:
This is possible by passing
fn.name
tomakeTimeoutMsg
here.vitest/packages/runner/src/context.ts
Line 50 in 926ca95
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: