E2E (End-to-End) testing checks if the whole app works as expected from the user's point of view. It tests all parts together, like clicking buttons and loading pages.
Click to reveal answer
beginner
What is Playwright used for in testing?
Playwright is a tool that automates browsers to run E2E tests. It can open pages, click buttons, fill forms, and check results automatically.
Click to reveal answer
intermediate
How do you start a Playwright test in Next.js?
You write a test file using Playwright's test functions. You open the page with `page.goto()`, interact with elements, and use assertions to check results.
Click to reveal answer
intermediate
Why use selectors like `data-testid` in Playwright tests?
Selectors like `data-testid` are stable and do not change often. They help tests find elements reliably without breaking when UI changes.
Click to reveal answer
beginner
What does a passing Playwright test report show?
It shows which tests ran and passed. If all tests pass, it means the app works as expected for those scenarios.
Click to reveal answer
What does E2E testing primarily verify?
AThe entire app works from user actions
BOnly the backend logic
CIndividual functions in code
DThe app's database schema
✗ Incorrect
E2E testing checks the whole app flow as a user would experience it.
Which Playwright method opens a web page in a test?
Apage.goto()
Bpage.open()
Cbrowser.launch()
Dtest.start()
✗ Incorrect
Use page.goto() to navigate to a URL in Playwright tests.
Why prefer `data-testid` selectors in tests?
AThey are visible to users
BThey change often with UI updates
CThey are faster to type
DThey are stable and do not affect UI
✗ Incorrect
`data-testid` attributes are stable and do not affect the user interface.
What does a failed assertion in Playwright indicate?
AThe test passed successfully
BThe test file is missing
CThe app did not behave as expected
DThe browser crashed
✗ Incorrect
A failed assertion means the app did not meet the expected condition.
Which command runs Playwright tests in a Next.js project?
Anext dev
Bnpm run test:e2e
Cnpm start
Dplaywright open
✗ Incorrect
Usually, `npm run test:e2e` runs Playwright tests if configured in package.json.
Explain how to write a simple E2E test with Playwright for a Next.js app.
Think about the steps a user takes and how to automate them.
You got /5 concepts.
Describe why stable selectors are important in E2E testing and how to implement them.
Consider what happens if UI changes but tests still need to work.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of E2E testing in a Next.js application using Playwright?
easy
A. To check only the backend API responses
B. To verify CSS styles and layout only
C. To test individual React components in isolation
D. To test the entire user experience from start to finish
Solution
Step 1: Understand E2E testing scope
E2E (end-to-end) testing simulates real user actions across the whole app, not just parts.
Step 2: Identify Playwright's role
Playwright automates browser actions to test full user flows, like clicking and filling forms.
Final Answer:
To test the entire user experience from start to finish -> Option D
Quick Check:
E2E testing = full user experience [OK]
Hint: E2E tests cover full user flows, not just parts [OK]
Common Mistakes:
Confusing E2E with unit or integration tests
Thinking E2E tests only check backend APIs
Assuming E2E tests verify only UI styles
2. Which of the following is the correct syntax to launch a browser and open a new page in Playwright for Next.js E2E testing?