From the course: Node.js: Testing and Code Quality
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Install Jest in a Node.js project
From the course: Node.js: Testing and Code Quality
Install Jest in a Node.js project
- [Instructor] We've been discussing the tools and theory around writing tests. Let's apply that knowledge by installing Jest. Two steps are necessary for installation. The first thing we need to do is use NPM to install Jest to the project's dev dependencies. Then, we'll edit package.json and add the definition for the test script, which will just be jest. Finally, we'll add an ESLint environment configuration for Jest globals. This isn't strictly required, but it will reduce a number of false positives from the linter. Let's switch over to VS Code. Open a terminal and make sure you're in the project directory. We're going to use NPM to install Jest to the dev dependencies dash capital D. Press Enter. After a moment, Jest and its dependencies will be installed. As we're using Jest for a test framework, we're going to have to add it to the scripts. In the Explorer, open up package.json. Find the script section and…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Survey of Node.js testing frameworks5m 5s
-
(Locked)
Install Jest in a Node.js project2m 25s
-
(Locked)
What and where to unit test?4m 46s
-
(Locked)
Writing your first Jest unit test4m 36s
-
(Locked)
Running a test suite with Jest6m 5s
-
(Locked)
Testing asynchronous callbacks with Jest5m 42s
-
(Locked)
Writing callback test suites with Jest6m 32s
-
(Locked)
Testing promises with Jest7m 52s
-
(Locked)
Challenge: Test async/await with Jest49s
-
(Locked)
Solution: Test async/await with Jest2m 51s
-
-
-
-