


It is part of the tests setupĭescribe allows you to group tests into units. Note that if your tests take a long time to run and a timeout value is not specified, your tests might fail.īeforeAll allows Puppeteer to navigate to the specified URL which was declared earlier as a global variable and tells it to waitUntil your content has loaded before it runs the test. This ensures that your tests run before timing out. Looking at the first line of your code, you assigned a value to a variable( timeout) that specifies the time duration for your tests. PASS src/ Test page title and header √ page title (20ms) Test Suites: 1 passed, 1 total Tests: 1 passed, 1 total Snapshots: 0 total Time: 0.746s, estimated 1s Ran all test suites. When it's done, you should get something like this: You can check out the state of JS 2020 testing frameworks. Knowing that Puppeteer is basically a programmable browser and Jest is a testing framework, therefore, in order to be able to test the User Interface, you would need to use Jest and puppeteer together. Why should we use Jest and Puppeteer together? The goal of end-to-end testing is to reproduce real user experience in order to validate data integrity and system integration. It helps to validate if an application is behaving as it should. This is a software testing technique used to test the flow of an application from beginning to end. Where unit testing is concerned with validating the smallest chunks of source code in isolation, integration testing finds errors in how these chunks interact with each other. It also simulates an actual user experience on your application.

It creates a programmable browser (in this case, but not always, a headless browser) to check your site. What is Puppeteer? Puppeteer is a Node library that provides a high-level API to control headless Chrome, Firefox, and Chromium over the DevTools protocol. It is a great testing library that requires little configuration. Jest is a Javascript testing framework that helps to ensure that our code-base is correct.

In Jest, there is truth - William Shakespeare
