bun-playwright-runner-selection
Skill4 starsChanged 2 days agoMITView on GitHub
Fix the error "Playwright Test did not expect test() to be called here" when a Playwright spec file is run with Bun's unit-test runner instead of the Playwright CLI. Use when: (1) a `*.spec.ts` file contains `import { test, expect } from '@playwright/test'`, (2) `bun test` was run on that file, and (3) the suite fails before any test runs. Run the suite with `bunx playwright test` instead.
In this repository50 other files it gives its agents.
- agent-writingSkill
- arenaSkill
- blast-radiusSkill
- cinematic-shotSkill
- clean-ui-shotSkill
- codebase-designSkill
- debug-loopSkill
- dep-upgradeSkill
- diagnosing-bugsSkill
- discoverSkill
- domain-modelingSkill
- earshotSkill
- eval-judgeSkill
- flaky-testSkill
- grillingSkill
- grillSkill
- idea-scoutSkill
- improve-codebase-architectureSkill
- interrogateSkill
- make-mediaSkill
- migrate-to-rustSkill
- migration-planSkill
- multi-agent-windows-hazardsSkill
- perf-loopSkill
- postmortemSkill
- prototypeSkill
- prSkill
- real-soundSkill
- recallSkill
- release-notesSkill
- repo-mapSkill
- researchSkill
- retroSkill
- secure-diffSkill
- sellSkill
- subagent-report-recoverySkill
- tasteSkill
- taste-skillSkill
- tddSkill
- teachSkill
- to-questionnaireSkill
- to-specSkill
- to-ticketsSkill
- wayfinderSkill
- weeklySkill
- windows-bash-backslash-halvingSkill
- wizardSkill
- writing-for-agentsSkill
- ycSkill
- ystack-upgradeSkill
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 16
Test. The suite fails before any test runs, with an error that points somewhere else.
- Distinctive: line 20
All of these hold:
- Very specific: line 42
Don't run it with bun test.
- Distinctive: line 43
Run the Playwright CLI through Bun's package runner:
- Very specific: line 55
Keep using Bun for installs and scripts.
- Very specific: line 86
If the error persists under bunx playwright test, then look at the usual Playwright causes: two versions of @playwright/test, or test() …
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Bun: run Playwright specs with the Playwright runner
Problem
In Bun-based repos it is easy to run a Playwright spec with the wrong runner. Passed to bun test, a
file that defines Playwright tests is treated as a Bun unit-test file instead of going to Playwright
Test. The suite fails before any test runs, with an error that points somewhere else.
Trigger conditions
All of these hold:
- The repo uses Bun for package management and scripts.
- The test file imports from
@playwright/test. - It was run with something like
bun test path/to/file.spec.ts. - The failure looks like:
Playwright Test did not expect test() to be called here.
Most common reasons include:
- You are calling test() in a configuration file.
- You are calling test() in a file that is imported by the configuration file.
- You have two different versions of @playwright/test.The message invites you to chase duplicate dependencies or bad imports when the only problem is the runner.
Solution
- Confirm the file is a Playwright spec, not a Bun unit test: it imports from
@playwright/testand uses fixtures such aspageorrequest. - Don't run it with
bun test. - Run the Playwright CLI through Bun's package runner:
bunx playwright test path/to/file.spec.ts- To pick specific tests, use Playwright's flags, not Bun's (
-tis a Bun flag):
bunx playwright test "path/to/file.spec.ts" --grep "test name"- Keep using Bun for installs and scripts; use the Playwright CLI for Playwright suites. A
package.jsonscript such as"e2e": "playwright test"(run withbun run e2e) stops the mistake from recurring.
Verification
- The
test()error is gone. - Playwright reports the expected number of tests (
Running N tests using M workers). - The run ends with Playwright's normal summary (
N passed).
Example
Wrong:
bun test tests/checkout.e2e.spec.ts -t "applies discount"
# error: Playwright Test did not expect test() to be called here.Right:
bunx playwright test tests/checkout.e2e.spec.ts --grep "applies discount"
# 1 passedNotes
- This is about runner choice, not a broken Playwright install.
bunxis Bun's equivalent ofnpxorpnpm execfor package CLIs, and it honours Node shebangs, sobunx playwright ...runs the Playwright CLI as intended.- If the error persists under
bunx playwright test, then look at the usual Playwright causes: two versions of@playwright/test, ortest()called from a file the config imports. - To keep
bun testfrom picking up e2e specs at all, keep them in a folder Bun's runner doesn't scan, or pointbun testat your unit-test paths explicitly.
References
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

