test.describe groups related scenarios and provides hooks for shared setup and teardown. This lesson shows how to structure suites cleanly.
Grouping with test.describe
Wrap related tests in test.describe('Feature name', () => { ... }). Nested describes further organize sub-features. Hooks like test.beforeEach run around each test in that describe block.
Use test.describe.configure({ mode: 'serial' }) when tests must run in order and share state — use sparingly because it disables parallelism within that group.
Steps appear in HTML reports and traces, making failures easier to pinpoint.
Hooks Inside describe Blocks
test.beforeEach runs before every test in the block; test.afterEach cleans up. Use test.describe.configure({ mode: 'serial' }) when tests in one file must run in order.
Common Mistakes
Using serial mode everywhere, destroying parallel performance.
Putting heavy setup in beforeEach when beforeAll with careful isolation would suffice.
Sharing mutable state between parallel tests in the same describe.
Deep nesting of describes that obscures which hooks apply.
Key Takeaways
test.describe organizes tests and scopes hooks.
Prefer beforeEach for navigation and clean state per test.
Use serial mode only when order-dependent behavior is unavoidable.
test.step improves report readability for long flows.
Pro Tip
Keep describe titles user-facing ('Checkout') not implementation-facing ('tests for CartReducer') — CI output becomes documentation.
Continue with Browser Context to build on what you learned here.