Quiz: Building a test framework
Why This Matters
A quick check that this module’s ideas hold up before you move on. Answer each question yourself before you open the answer.
1. A test passed on its second attempt. What does Playwright report and what should you do?
- A. Passed; nothing to do
- B. Flaky; find the cause, because retries only hide it
- C. Failed; delete the test
- D. Skipped; rerun the pipeline
Show answer
2. Where does an assertion about behaviour belong?
- A. Inside the page object
- B. In the test, so the reader sees what is checked
- C. In a fixture
- D. In the config
Show answer
3. What runs after await use(value) in a fixture?
- A. Nothing;
useends the fixture - B. The teardown, after the test, also when the test failed
- C. The next test
- D. The fixture’s setup again
Show answer
use hands the value to the test and waits for it to finish. Cleanup after use runs whatever happened in the test, which is why cleanup belongs there and not at the end of the test body.4. Which data is safe to put in a worker-scoped fixture?
- A. A cart that tests add products to
- B. A logged-in user whose settings tests change
- C. The product catalogue, which no test changes
- D. The current order
Show answer
5. Two tests pass alone and fail now and then when run together with four workers. Most likely cause?
- A. The browser is unstable
- B. The tests share data, such as one cart or one user
- C. Four workers is too many
- D. The tests need more retries
Show answer
6. A login test types the username, but the form says “Username is required.” It only happens on slow machines. Most likely cause?
- A. A bug in Playwright’s
fill - B. The test typed before the front-end framework had hydrated the form
- C. The username is wrong
- D. The test needs
waitForTimeout(2000)
Show answer
toPass until the form responds as expected, with a comment saying why.7. What does npm run test:smoke give you that the full suite does not?
- A. Better coverage
- B. A fast check of the main paths before you push
- C. Visual tests
- D. Retries
Show answer
8. Several pages show the same header navigation. How do you model it?
- A. A
BasePagewith navigation methods that every page extends - B. A
SiteNavcomponent that pages have, scoped to the “Main navigation” landmark - C. Copy the navigation locators into every page object
- D. A global variable with the link selectors
Show answer
SiteNav, a page without it does not. A BasePage grows into a class every page inherits everything from. The scoping matters too: the footer has links with the same names.9. A test creates shop.product("Smartphone Stand") while the Smartphone Stand is not on the current page yet, then sorts by price and asserts on the card. Does that work?
- A. No, the constructor throws because the card does not exist
- B. Only with
awaitin the constructor - C. Yes: locators are lazy and are resolved when an action or assertion uses them
- D. Only if the test reloads the page first