Skip to content

Commit ab9e51e

Browse files
authored
test(nuxt): Fix flaky test and add note about hydration timing to skill (#21054)
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
1 parent f002b7a commit ab9e51e

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

.agents/skills/write-tests/SKILL.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,22 @@ test('captures transactions for all routes', async ({ baseURL }) => {
465465
});
466466
```
467467

468+
### SSR hydration timing
469+
470+
In SSR apps (Nuxt, SvelteKit, Next.js), elements are visible before framework event handlers attach.
471+
Playwright's actionability checks pass on server-rendered HTML, so `.click()` can fire before
472+
hydration, making it a no-op and timing out `waitForError`. Wait for the Sentry SDK before
473+
interacting:
474+
475+
```typescript
476+
await page.goto(`/test-param/1234`);
477+
await page.waitForFunction(() => typeof window.__SENTRY__ === 'object');
478+
await page.locator('#errorBtn').click();
479+
```
480+
481+
Don't use `networkidle`. Playwright discourages it. Use `waitForFunction` with a condition that
482+
directly proves readiness.
483+
468484
### Common pitfalls
469485

470486
- **Proxy name mismatch:** `APP_NAME` must match `proxyServerName` in `start-event-proxy.mjs`.

dev-packages/e2e-tests/test-applications/nuxt-3-dynamic-import/tests/errors.client.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ test.describe('client-side errors', async () => {
3535
});
3636

3737
await page.goto(`/test-param/1234`);
38+
await page.waitForFunction(() => typeof window.__SENTRY__ === 'object');
3839
await page.locator('#errorBtn').click();
3940

4041
const error = await errorPromise;

0 commit comments

Comments
 (0)