test(nuxt): Fix flaky test and add note about hydration timing to skill#21054
Open
s1gr1d wants to merge 1 commit into
Open
test(nuxt): Fix flaky test and add note about hydration timing to skill#21054s1gr1d wants to merge 1 commit into
s1gr1d wants to merge 1 commit into
Conversation
Comment on lines
35
to
41
| }); | ||
|
|
||
| await page.goto(`/test-param/1234`); | ||
| await page.waitForFunction(() => typeof window.__SENTRY__ === 'object'); | ||
| await page.locator('#errorBtn').click(); | ||
|
|
||
| const error = await errorPromise; |
Contributor
There was a problem hiding this comment.
Bug: A race condition in the test may cause a click on #errorBtn to occur before Vue hydration, potentially leading to a flaky test.
Severity: LOW
Suggested Fix
Before attempting to click the #errorBtn, introduce a wait mechanism to ensure the Vue application has completed client-side hydration. This could involve waiting for a specific element that appears after hydration or using a more robust selector that guarantees interactivity.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location:
dev-packages/e2e-tests/test-applications/nuxt-3-dynamic-import/tests/errors.client.test.ts#L35-L41
Potential issue: A potential race condition exists in the 'captures error thrown on
click' test. The test navigates to the `/client-error` page and immediately clicks the
`#errorBtn` element. However, the `@click` handler for this button is attached by Vue
only after the client-side application has fully hydrated. If the click occurs before
hydration is complete, the event handler will not be present, the click will have no
effect, and the test may time out. This can lead to flaky test results, particularly in
high-load CI environments where hydration might be slower.
Did we get this right? 👍 / 👎 to inform future reviews.
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.
Fixes flaky test and also adds a note about how to properly test something like this to our test skill (because AI tends to fix that with the discouraged
networkidleoption): https://playwright.dev/docs/api/class-page#page-wait-for-load-stateCloses #21047