arrow-left Back to topicQuizParameterize testsCheck yourself1.You want to test the same form validation with 5 invalid inputs. What's the cleanest approach?Write 5 separate test() functions with different input valuesLoop over an array of inputs with for...of and generate a test() for eachPut all 5 checks inside a single test with multiple expect() calls2.How does Playwright name each generated test when you use a for...of loop to create parameterized tests?All generated tests share the same name — only the index differs in the reportEach test title is whatever string you pass to the test() call, which typically includes the parameter value via a template literalPlaywright appends [1], [2], [3] to the base test name automaticallyThe test names are read from the data array keys3.You place a beforeEach hook outside the for...of loop that generates parameterized tests. How many times does beforeEach run per test run?Once before the entire loop startsOnce before each generated test — same as with manually written testsOnce per iteration of the loop, not per testNever — beforeEach is ignored when tests are generated in a loop4.How can you run parameterized tests for the same data set in parallel within one test file?Add parallel: true to each test() options objectAdd test.describe.configure({ mode: 'parallel' }) at the top of the file or inside the describe block containing the loopUse test.concurrent() instead of test() for each generated testSet workers: 'auto' in the playwright.config.ts for that project5.You have test data in a CSV file. What is the typical approach to load it for parameterized Playwright tests?Use a built-in Playwright CSV reader: test.loadCSV('data.csv')Read and parse the file with Node.js fs and a CSV parser before the for...of loop, then iterate over the resulting arrayStore the CSV in the playwright.config.ts testData field and Playwright will import it automaticallyEmbed the CSV rows as a multiline string inside the test file6.What is the project-level parameterization approach and when would you choose it over test-level forEach?Project-level means running each test with a random seed — use it for security testingProject-level means declaring a custom fixture option and creating one project per value (e.g. one per user role) — use it when the entire test suite should run as different personasProject-level parameterization runs tests against multiple baseURLs sequentially in a single projectIt is the same as test-level forEach but the loop is declared inside playwright.config.ts7.You want to switch the tested environment (staging vs production) using an environment variable. Where do you read the variable to set baseURL?Inside each test using process.env before calling page.goto()In playwright.config.ts in the use.baseURL field, evaluated at config load timeIn a globalSetup file and stored back to process.envIn a .env file that each test imports directly8.Which of these is NOT a valid reason to use test-level parameterization with a for...of loop?Testing the same form submission with multiple invalid inputsRunning the same test against multiple browsers (chromium, firefox, webkit)Checking multiple order status badges render with the correct coloursVerifying that five different locale-specific date formats display correctlySubmit answersarrow-left PreviousPage object modelsGlobal setup and teardownNext arrow-right