chore: Playwright e2e testing enhancements#777
chore: Playwright e2e testing enhancements#777danielroe merged 2 commits intonuxt:feat/playwright-runnerfrom
Conversation
| @@ -0,0 +1,28 @@ | |||
| import { test as base } from '@playwright/test'; | |||
There was a problem hiding this comment.
Ideally we ship this whole file inside the test-utils package, so that the user does not have to think about it. If the user wants to customise it, he can extend from it.
Edit: Addressed
examples/app-playwright/package.json
Outdated
| "playwright": "^1.42.1", | ||
| "@nuxt/test-utils": "latest" | ||
| "@nuxt/test-utils": "latest", | ||
| "@playwright/test": "1.43.0-alpha-2024-03-14" |
There was a problem hiding this comment.
Note: thats the alpha version with the fix: microsoft/playwright#29865
| rootDir: fileURLToPath(new URL('.', import.meta.url)), | ||
| } | ||
|
|
||
| export default defineConfig<ConfigOptions>({ |
There was a problem hiding this comment.
Thought: Ideally we mirror here a similar default config like we have here: https://github.com/microsoft/create-playwright/blob/main/assets/playwright.config.ts
Edit: Addressed
| test('test', async ({ page }) => { | ||
| await page.goto(url('/')) | ||
| test.expect(await page.getByRole('heading').innerText()).toBe('Welcome to Playwright!') | ||
| await page.goto('/') |
There was a problem hiding this comment.
Instead of relying on the url() function from the test-utils package, we use Playwright's baseURL.
| await page.goto(url('/')) | ||
| test.expect(await page.getByRole('heading').innerText()).toBe('Welcome to Playwright!') | ||
| await page.goto('/') | ||
| await expect(page.getByRole('heading')).toHaveText('Welcome to Playwright!') |
There was a problem hiding this comment.
These assertions, which we call "web-first assertions" will automatically retry over and over again until the condition is met or the timeout has been reached (they are non-flaky).
65da6af to
486bf86
Compare
No description provided.