arrow-left Back to topicQuizFixturesCheck yourself1.In a fixture, what happens AFTER await use(value)?Nothing — the fixture function endsThe teardown code runs — cleanup after the testThe next test's setup begins2.You want to create a database connection that's shared across all tests in a worker (not recreated per test). What scope do you use?{ scope: 'test' } — the default{ scope: 'worker' } — shared across all tests in one parallel worker{ scope: 'global' } — shared across all tests in the entire run3.How do you create a custom fixture and make it available to test files?Call test.addFixture() anywhere in the test file before using itUse test.extend<Fixtures>({...}) to create a new test object and export it; test files import this extended test instead of @playwright/testRegister fixtures in playwright.config.ts under the fixtures keyDeclare fixtures as global variables and use beforeAll to initialise them4.A fixture is defined but a test does not list it in its argument list. When does Playwright run that fixture?Always — fixtures always run for every test whether or not they are requestedNever — fixtures are on-demand and only run when a test explicitly requests themOnly when the test file imports the fixture moduleOnly on the first test in the file5.Which of the following are built-in Playwright fixtures available in every test without any custom setup?page, context, browser, request, browserNamepage, context, fetch, driver, browserNamepage, window, storage, request, browserNamepage, context, browser, apiContext, platform6.You want to override the built-in page fixture to automatically navigate to the base URL before every test. What is the correct approach?Add a beforeEach hook in every test file that calls page.goto(baseURL)Use test.extend({ page: async ({ baseURL, page }, use) => { await page.goto(baseURL!); await use(page) } }) and export the resultSet autoNavigate: true in the playwright.config.ts use blockOverride page in globalSetup by calling browser.newPage() with a startURL option7.Why are fixtures considered better than beforeEach/afterEach for sharing setup and teardown?Fixtures run faster because they skip the browser startup stepFixtures keep setup, the value, and teardown in one place; tests declare dependencies explicitly; and fixtures only run when actually neededFixtures are the only way to share state between parallel workersFixtures automatically retry when they fail, unlike beforeEach hooks8.A fixture function receives ({ page, browser }, use) as arguments. What does this mean?The fixture depends on both the page and browser fixtures — Playwright will create them first before running this fixtureThe fixture receives a copy of the page and browser objects from the previous testThe fixture will run twice — once for page and once for browserThe fixture overrides both the page and browser built-in fixtures at the same timeSubmit answersarrow-left PreviousTimeoutsParallelismNext arrow-right