Installing and Running Jest
Learn to use Jest in the local code editor in this lesson.
The importance of learning to use Jest locally
The majority of the lessons in this course have code widgets that allow you to take exercises directly in the browser without installing anything locally. This is great for learning many topics in this course.
However, you will likely use Jest on your machine in a real-world project and interact with its command-line interface.
If you don’t have a code editor or Node.js installed on your machine, visit the appendix to help you do so.
Installing Jest
Open the starter project in the code editor of your choice. The isEmail
function with its tests in the src
folder should be visible. There is also an isUrl
function with some tests.
If you are unsure of how to begin from the starter project, visit the appendix.
To install Jest into the project, execute the following command in a terminal window:
npm install --save-dev jest
This will install Jest into the project as a development dependency.
Allowing Jest to work with ESM
By default, Jest works with code written with CommonJS modules. However, we are used to working with ECMAScript modules (ESM) when ...