Skip to content

test(nuxt): Fix flaky test and add note about hydration timing to skill#21054

Open
s1gr1d wants to merge 1 commit into
developfrom
sig/fix-nuxt-3-flake
Open

test(nuxt): Fix flaky test and add note about hydration timing to skill#21054
s1gr1d wants to merge 1 commit into
developfrom
sig/fix-nuxt-3-flake

Conversation

@s1gr1d
Copy link
Copy Markdown
Member

@s1gr1d s1gr1d commented May 20, 2026

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 networkidle option): https://playwright.dev/docs/api/class-page#page-wait-for-load-state

Closes #21047

@s1gr1d s1gr1d requested a review from Lms24 May 20, 2026 09:07
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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant