arrow-left Back to topicQuizGlobal setup and teardownCheck yourself1.You set up a globalSetup function that logs in, saves storageState, and also starts tracing to capture what happens during login. But when login fails in CI, you get no trace file. Why?globalSetup doesn't support tracing at allTracing is supported in globalSetup but you must stop the trace in a try/catch before re-throwing the error — otherwise the trace file is never written because the error exits the function before tracing.stop() runsSwitch to project dependencies — they support tracing automatically without any extra codeThe CI environment blocks file writes from globalSetup2.Why does the documentation recommend project dependencies over globalSetup for the login-once pattern?Project dependencies run faster because they use parallel workersProject dependencies appear in the HTML report, support full trace recording, and give access to Playwright fixtures like { browser } and { request } — globalSetup has none of theseglobalSetup is deprecated and will be removed in a future Playwright versionProject dependencies automatically retry failed setup steps3.What does await page.context().storageState({ path: authFile }) save?Only the session cookies from the current domainBoth cookies and localStorage/sessionStorage for all domains visited — everything needed to restore the authenticated sessionThe browser's full state including open tabs and navigation historyOnly the authentication token stored in localStorage4.In playwright.config.ts, how do you make the 'chromium' project run only after the 'setup' project finishes?Set order: 1 in the 'setup' project and order: 2 in the 'chromium' projectAdd dependencies: ['setup'] in the 'chromium' project configurationName the setup project 'setup' — Playwright runs any project named 'setup' first automaticallyUse testProject.before() to declare setup as a prerequisite5.You use globalSetup to seed a test database and store the seed IDs in process.env. Will the tests be able to read those environment variables?No — globalSetup runs in a separate process, so process.env changes don't reach test workersYes — Playwright serializes process.env changes from globalSetup and injects them into each test worker processOnly if you explicitly use dotenv to write the variables to a .env fileOnly on CI — locally process.env is isolated per process6.You're debugging a single test that depends on the 'setup' project. You know the storageState file already exists from the last run. How do you run just that test without re-running the login setup?Delete the dependencies array from the chromium project temporarilyRun with --no-deps flag — skips dependent projects and runs only the selected test directlyRun with --skip-setup — the dedicated flag for skipping setup projectsThere's no way to skip dependencies — they always run for correctness7.The 'setup' project has a teardown: 'cleanup' option. When does the cleanup project run?Immediately after the setup project finishes, before any tests runAfter all test projects that depend on 'setup' have finished runningAfter each individual test that depended on the setup projectOnly if the tests fail — it's a failure handler8.You run npx playwright test --grep 'checkout' to filter tests. The checkout tests depend on the 'setup' project. Does the setup project still run?No — --grep only runs matching tests and skips all dependencies to save timeYes — Playwright still runs dependent projects first; you need --no-deps to explicitly skip themOnly if the storageState file is missing — Playwright checks before running setupIt depends on whether the setup project tests also match the --grep patternSubmit answersarrow-left PreviousParameterize testsNetworkNext arrow-right