Writing tests with Jest
In this section, you'll learn how to write tests using the Jest framework in JavaScript projects.
Jest is a fast and reliable test framework for JavaScript projects focusing on simplicity. It works with Babel, TypeScript, Node, React, Angular, Vue, and other tools.
After installing it, we can start using Jest without any extra configuration. In our case, we can write a test and run the test
command configured in our project without even installing Jest, as Umi already provides Jest with the umi-test
package.
Consider this end-to-end test written with Jest to test the login flow:
it('[END_TO_END] Should sucessfully login', async () => { const page = await context.newPage(); await page.goto('http://localhost:8000'); await page.waitForNavigation(); await page.type('#username', 'john@doe.com'); await page.type('#password', &apos...