Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Course Introduction: Testing with Puppeteer and Jest

    Tyler ClarkTyler Clark

    The goal of this course is to teach you how to use the tools to write end to end tests. End to end testing involves assuring that all the integrated pieces of an application function and work together as expected. These types of tests simulate real user scenarios, essentially testing how a real user would use the application. They fill the gaps that unit and integration tests just can't cover.

    Puppeteer is a core piece of these tools. When used correctly it can open and run applications inside a chromium browser and perform the actions it's given. Jest is used to assert that the integrated pieces work as expected and other add-on libraries such as faker and pixelmatch, take our tests to the next level.



    Become a Member to view code

    You must be a Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson




    Instructor: In this course, we're going to walk through many different aspects of Google's Puppeteer, and how we can use it to write in the end test. Puppeteer is a Node library which provides a high-level API to control Chromium over the DevTools Protocol.

    We'll start off our course by learning how to set up conditional testing with environment variables. This is helpful when wanting to run the test in headless mode or not. The raw power of Puppeteer comes from being able to have up-to-date browser to test the end results of your application.

    Within this course, there are a couple of lessons where we'll learn how to do something as basic as testing that the text within an h1 is correct, to actually stepping through a form and submitting it. We'll mimic user activity with mouse clicks, and use a library that will create random user info every time you run the test.

    We'll also test our application in an iPhone 6 view. In this view, instead of replicating mouse clicks, we'll use touchscreen events to make sure our application works in different contexts.

    Within the other lessons in this course, we will walk through situations where applications save and require document cookies for features. We'll log and test for console errors that might get thrown while stepping through different attributes, and intercept HTTP requests to test our application's error handling.

    The finale of this course is using pixelmatch, which is a pixel-level image comparison library. This entails rendering our application, taking a screenshot, and then comparing the screenshot with a previously accepted image of the application.

    Pixelmatch will compare the two and let us know how many pixels the images are off by.