fix(browser): correctly calculate timeout in hooks when actions are performed#7747
Merged
sheremet-va merged 1 commit intovitest-dev:mainfrom Mar 28, 2025
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR fixes the calculation of timeouts in hooks when actions are performed in the browser context. It adjusts error message expectations and test snapshots for timeout errors, updates the runner to track the start time and timeout per task, and propagates these changes through the browser client and tester utilities.
- Updated test expectations in browser tests by removing deprecated playwright-specific tests and changing the expected error line numbers.
- Enhanced timeout tracking by adding private properties to the runner and clearing them appropriately after test execution.
- Adjusted browser client state to include the runner and updated the processTimeoutOptions logic to use the new timeout properties.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| test/browser/test/failing.test.ts | Removed playwright-specific tests and updated error matching criteria |
| test/browser/specs/runner.test.ts | Adjusted expected error snapshot line numbers and renamed a test case |
| test/browser/fixtures/timeout-hooks/vitest.config.ts | Added a dedicated configuration for timeout hooks tests |
| test/browser/fixtures/timeout-hooks/hooks-timeout.test.ts | Introduced new tests for verifying timeout hooks behavior |
| packages/runner/src/types/runner.ts | Added private properties (_currentTaskStartTime, _currentTaskTimeout) to track timeout details |
| packages/runner/src/context.ts | Updated the withTimeout function to set and clear the runner timeout properties |
| packages/browser/src/client/utils.ts | Extended the BrowserRunnerState interface with a runner property |
| packages/browser/src/client/tester/utils.ts | Modified processTimeoutOptions to compute timeout based on the runner properties |
| packages/browser/src/client/tester/tester.ts | Set the runner in the browser state to facilitate updated timeout logic |
Comments suppressed due to low confidence (3)
packages/runner/src/context.ts:49
- Consider adding a null check for the object returned by getRunner() to avoid potential runtime errors if the runner is unexpectedly undefined.
const runner = getRunner()
packages/browser/src/client/tester/utils.ts:147
- Ensure that getBrowserState().runner is properly initialized before processTimeoutOptions is called to prevent potential undefined behavior.
const runner = getBrowserState().runner
test/browser/specs/runner.test.ts:180
- [nitpick] Verify that the updated error matching pattern with the new line number accurately reflects the current code locations after the refactor.
expect(stderr).toMatch(/test\/failing.test.ts:25:(2|8)/)
✅ Deploy Preview for vitest-dev ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
AriPerkkio
approved these changes
Mar 28, 2025
1 task
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #7694
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.