Good introduction to using Puppeteer for your e2e tests:
One of the most popular tools for e2e testing is Selenium, which is a tool for automating web browsers. Selenium sounds cool in theory: write one set of tests that run on all browsers and devices, woohoo! Jk. In practice, Selenium tests are slow, brittle, and costly. So, on Ropig we are using Puppeteer – the official headless Chrome library.
[…]
We are using Jest as our test runner, but you can use any testing tools you want with Puppeteer.
An example test would be this:
test('can create new user account', async () => {
await page.goto(routes.public.register);
await page.waitForSelector('[data-testId="userAccountForm"]');
await page.click('[data-testId="userRegisterInputWithEmail"]');
await page.type(user.email);
await page.click('[data-testId="userRegisterInputWithPassword"]');
await page.type(user.password);
await page.click('[data-testId="userAccountSubmitButton"]');
await page.waitForSelector('[data-testId="userSettingsForm"]');
})
Yes, you better get your async/await mojo on for this 😉