End-to-end Tests that Don’t Suck with Puppeteer

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 😉

End-to-end Tests that Don’t Suck with Puppeteer →

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.