Writing and running end-to-end tests
We are now going to write and run our first end-to-end test with Playwright. Let’s start with a simple test, which just verifies that we have properly optimized our title for search engines. Follow these steps to write and run your first end-to-end test:
- Create a new
tests/seo.spec.jsfile. Inside this file, we are going to check whether the title of our page is set properly. - Inside this newly created file, first import the
testandexpectfunctions from@playwright/test:import { test, expect } from '@playwright/test' - Then, we define a test in which we check whether the title of the blog is set properly:
test('has title', async ({ page }) => {As you can see, the
testfunction is similar to how we defined tests in Jest. Playwright additionally allows us to access special contexts in our test, called fixtures. Thepagefixture is the most essential fixture in Playwright and allows us to access browser features...