The Playwright Test for VSCode extension is the easiest way to run individual tests or test suites. It covers the vast majority of standard debugging use cases and supports debugging directly in VS Code.
You can run or debug tests from the side bar:
Note: the application will start automatically if it's not already running. This could take some time and doesn't provide a lot of output.
Or directly from the spec files (right-click for more options e.g. debug):
Notice the useful options in the test side bar above:
Show browser
for running tests in headed modeReveal test output
for viewing test logs
Note: the extension can become unstable if there are compilation errors in the code.
Standard usage:
- From root:
pnpm exec playwright test -c ./test/e2e/playwright.config.ts [other options]
- Or simply:
pnpm run test-e2e [-- other options]
Tips:
test-e2e-report
opens the latest HTML report with results, traces & screenshots (valuable for debugging after the fact)await page.pause()
acts as a breakpoint in--headed
and--debug
mode- Playwright's debugging inspector provides a toolkit for debugging Playwright locators. It is available in
--debug
mode or by usingawait page.pause()
in--headed
mode - Test for flakiness by running tests multiple times
--repeat-each <N>
and only running specific tests withtest.only(...)
ortest.skip(...)
For a full list of options see the official docs.
- For performance reasons, we persist user sessions in
storageState.json
files, so that we can reuse them across tests and test executions. These are automatically removed when starting the server and automatically created if they do not exist. If the sessions become invalid they can lead to peculiar test failures. Remove them withmake clean-test
.