Fixtures and Test Config
The runner's setup model: what it hands a test, what you write yourself, and the config file shaping projects, ordering, timeouts and signed-in state. Interviewers probe where setup belongs.
on this pageshowhide
explore
- Injected Setup16 questions
- Provided Page and Context5 questions
- Extending the Base6 questions
- Worker Scope Reuse5 questions
- Runner Settings15 questions
- Project Matrix5 questions
- Preconditions and Teardown5 questions
- Timeout Budgets5 questions
- Signed-In State10 questions
- Reusing Saved Sessions5 questions
- Per-Role Credentials5 questions
questions
page 2 of 2Playwright loads a saved storageState, yet the admin console still renders signed out — how do you diagnose it?
basics
~20 sOpen the JSON and compare it with the address under test. Usual causes are an origins entry recorded for a different origin, a session kept in sessionStorage which the file never captures, or state saved before the application had written it.
A Playwright fixture that seeds admin-console staff accounts takes 45 seconds and every test times out. What do you change?
basics
~20 sFixture setup is charged to the test timeout by default, so a 45-second fixture blows a 30-second budget. Give that fixture its own timeout in its options tuple instead of raising the suite-wide timeout for every test.
Why do a Playwright suite's tests pass alone yet fail in sequence once their setup moved to a worker-scoped fixture?
basics
~20 sA Playwright worker-scoped fixture is built once and the same instance is given to every test that worker runs, so a mutation by one test survives into the next. Run alone, a test always gets a freshly built value.
In Playwright, how do you decide what becomes a custom fixture and what stays in test.beforeEach?
basics
~20 sSetup that produces something the test uses belongs in a fixture: it names what it provides, pairs its own teardown, and runs only for tests that ask for it. Local arrangement for one file can stay in a hook.
Your Playwright suite spends six minutes in setup projects before any test starts -- how do you decide what stays a suite-level precondition?
basics
~20 sJudge each step by who needs it, how often it must run, and whether it needs a browser. Split one broad setup project into narrow ones so a project waits only for what it lists.
When should a new variation in a Playwright suite become another entry in `projects` rather than a `test.use()` in the spec files?
basics
~20 sMake it a project when the variation is an axis the whole suite should run under and be reported on separately. Keep it in test.use when only certain specs need it, since a project re-runs everything.
In Playwright, what does a run-wide globalTimeout buy a CI pipeline that per-test timeouts cannot?
basics
~20 sglobalTimeout caps the wall-clock duration of an entire Playwright run and defaults to no limit. Per-test budgets bound one test each, so a large suite and its retries can still run for hours with no test misbehaving.
In a growing Playwright suite, how do you decide which setup earns worker scope over test scope?
basics
~20 sPromote a Playwright fixture to worker scope only when its value is read-only once built and its setup cost is measured and material. Test scope stays the default, because per-test isolation is what keeps a suite diagnosable as it grows.
In Playwright Test, how does a test find out which browser engine it is running in?
basics
~10 sBy destructuring the built-in browserName fixture, which is a plain string: chromium, firefox or webkit. Tests use it to branch, most often to skip a case that cannot run on one engine.
In Playwright, how do you use two separately extended test objects in one spec file?
basics
~20 sCombine them with mergeTests from the Playwright test package: mergeTests(staffTest, auditTest) returns one test object carrying both fixture sets. Importing both objects side by side does not work, and mergeExpects does the same job for custom matchers.
When would you pass the object from context.storageState() to browser.newContext instead of a file path?
basics
~20 sUse the object when one process both mints and consumes the session: context.storageState() with no path returns it, and browser.newContext accepts it directly. Use a file path when another process, run or config must read the state.
showing 31–41 of 41