- Want to see the entire bun-create-playwright project? It is on tinyurl.com/bun-create-playwright!
With this post, we will explore how the built-in test runner for Playwright Test can run headed tests, debug versions of tests, and smoke tests.
... and shortcuts for all of these can be set up in the scripts in your package.json! If you are using "bun" as a package manager, as we are in bun-create-playwright, just type out "bun run", a space and then the shortcut such as: bun run test
package.json
"scripts": {
"test": "playwright test",
"test:headed": "playwright test --headed",
"test:trace": "playwright test --trace on",
"test:chromium": "playwright test --project=chromium",
"test:firefox": "playwright test --project=firefox",
"test:webkit": "playwright test --project=webkit",
"test:smoke": "playwright test --project=chromium --grep '@smoke'",
"test:flaky": "playwright test --project=chromium --repeat-each=20",
"test:ui": "playwright test --ui",
"test:debug": "playwright test --debug",
"test:failed": "playwright test --last-failed",
"test:login": "playwright test tests/login.spec.ts",
"test:secure-area": "playwright test tests/secure-area.spec.ts",
"report:list": "playwright test --reporter=list",
"report:line": "playwright test --reporter=line",
"report:dot": "playwright test --reporter=dot",
"report:blob": "playwright test --reporter=blob",
"report": "playwright show-report",
"codegen": "playwright codegen",
"lint": "eslint .",
"lint:ci": "eslint . --max-warnings 0",
"lint:fix": "eslint . --fix",
"format": "prettier --write .",
"format:check": "prettier --check .",
"format:debug": "prettier --check . --log-level debug",
"format:diff": "prettier --list-different",
"typecheck": "tsc --noEmit"
},
Do you need to really set up shortcuts like these? Certainly not! But it is easier than typing out: bunx playwright test --project=chromium --grep '@smoke'.
Feel free to name these commands anything you want!