API …
Playwright lab

Fixtures: scopes & page objects

Learn test.extend: test and worker scope, page-object fixtures, auto and option fixtures, with a simulator and a Todo app to practise on.

Practice tasks

  • Run the simulator with worker scope and 2 workers and assert db setups is 2. Switch to test scope and assert it is 6.
  • Turn fullyParallel off and assert that only Worker 1 lists tests.
  • Tick “Test 3 fails” with worker scope and explain why workers started becomes 3 (use sim-event entries).
  • Build a TodoPage page object and expose it as a todoPage fixture with test.extend.
  • Write a test that adds two todos, completes one and asserts “1 item left”.
  • Add a duplicate todo and assert the todo-error message; then add an empty one.
  • Create an option fixture defaultItem and override it with test.use().
  • Write an auto fixture that fails the test when a page error occurs.

More Playwright lab practice