Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
JavaScript Unit Testing - The Practical Guide
Bestseller
Highest Rated
Rating: 4.6 out of 5(5,390 ratings)
32,261 students

JavaScript Unit Testing - The Practical Guide

Learn how to write automated tests (unit & integration tests) for your JavaScript projects with Vitest & Jest.
Last updated 1/2024
English

What you'll learn

  • Write and structure unit & integration tests
  • Remove side effects from tests via mocking and spies
  • Work with popular JavaScript test runners and libraries
  • Write good tests and focus on testing core business logic

Course content

10 sections92 lectures5h 36m total length
  • Welcome To This Course!0:54

    Explore automated unit and integration tests for JavaScript, with practical explanations and demos that cover what testing is, why to add tests, and how to write them.

  • What Is Testing?4:41

    Explore the difference between manual and automated testing, learn why automated tests ensure consistent, high-coverage checks of software and websites, and how to implement them alongside manual testing.

  • Unit Testing: What & Why?4:33

    Learn what unit testing is and why it matters: test individual units—functions and classes—to catch breaks when you change code, verify different behaviors, reduce manual testing, and encourage cleaner code.

  • Unit vs Integration vs E2E Tests5:51

    Compare unit, integration, and end-to-end testing to validate different parts and flows of your app. Use a testing pyramid to balance unit tests, integration tests, and key end-to-end tests.

  • A Quick Note About Test-Driven Development (TDD)1:35

    Explore test-driven development as a philosophy that writes failing tests first, defines expected behavior, then implements and refactors code to meet the tests, iterating with new tests.

  • About This Course6:42

    Set up a testing environment and learn the fundamentals of automated unit testing in JavaScript, with demos, mocks and spies, integration tests, and DOM testing, plus practical guidance and resources.

  • Join Our Learning Community0:24
  • Course Resources & Project Snapshots0:16

Requirements

  • Basic JavaScript knowledge is required
  • NO prior testing knowledge is necessary at all

Description

Automated testing is a key concept in modern (web) development.

It is a concept that can be intimidating at first, hence many developers shy away from diving into testing and adding tests to their projects.

This course teaches you automated unit & integration testing with JavaScript from the ground up. You will learn how tests are written and added to your projects, what should (and should not) be tested and how you can test both simple as well as more complex code.

You will learn about the software and setup required to write automated tests and example projects will be provided as part of the course. It's a hands-on, practical course, hence you won't get stuck in theory - instead you'll be able to learn all key concepts at real examples.

In the course, Vitest will be used as the main testing library & tool. It's a modern JavaScript test runner and assertion library that provides Jest compatibility. Hence what you'll learn in this course will help you no matter if you're working with Vitest or Jest. And the core concepts will apply, no matter which testing setup you're using at all!

As part of this course, typical testing problems will be defined and solved and common strategies like mocking or working with spies are taught in great detail. This course also does not focus on specific types of JavaScript projects - neither does it focus on any specific library or framework.

Instead, you'll learn how to automatically test your (vanilla) JavaScript code, no matter if it's a NodeJS or frontend project. The fundamentals you'll gain in this course will help you in all your future projects - backend (NodeJS) and frontend (vanilla JS, React, Vue, Angular) alike.

This course will provide you with an extremely solid foundation to build up on, such that you can start adding tests to all your JavaScript projects.

In detail, this course will teach you:

  • What exactly "testing" or "automated testing" is (and why you need it)

  • What "unit testing" is specifically

  • Which tools you need to enable automated unit tests in your projects

  • How to write unit tests

  • How to get started with integration tests

  • How to formulate different expectations (assertions)

  • Which patterns to follow when writing tests

  • How to test asynchronous and synchronous code

  • How to deal with side effects with help of spies & mocks

  • How to apply all these concepts in real projects & examples

Who this course is for:

  • JavaScript developers who want to add tests to their projects
  • Developers who always considered automated testing to be intimidating