JavaScript Unit Testing The Practical Guide

Learn how to write automated tests (unit & integration tests) for your JavaScript projects with Vitest & Jest.
JavaScript Unit Testing The Practical Guide
File Size :
2.23 GB
Total length :
5h 36m

Category

Instructor

Academind by Maximilian Schwarzmüller

Language

Last update

Last updated 11/2022

Ratings

4.7/5

JavaScript Unit Testing The Practical Guide

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

JavaScript Unit Testing The Practical Guide

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.Yet 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 will teach 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 specificallyWhich tools you need to enable automated unit tests in your projectsHow to write unit testsHow to get started with integration testsHow to formulate different expectations (assertions)Which patterns to follow when writing testsHow to test asynchronous and synchronous codeHow to deal with side effects with help of spies & mocksHow to apply all these concepts in real projects & examples

Overview

Section 1: Getting Started

Lecture 1 Welcome To This Course!

Lecture 2 What Is Testing?

Lecture 3 Unit Testing: What & Why?

Lecture 4 Unit vs Integration vs E2E Tests

Lecture 5 A Quick Note About Test-Driven Development (TDD)

Lecture 6 About This Course

Lecture 7 Join Our Learning Community

Lecture 8 Course Resources & Project Snapshots

Section 2: Setup & Testing Software

Lecture 9 Module Introduction

Lecture 10 Which Tools Are Needed For Testing?

Lecture 11 Jest & Vitest

Lecture 12 Installing Vitest

Lecture 13 Course Project Setup

Section 3: Testing Basics

Lecture 14 Module Introduction

Lecture 15 Basic Test File & Project Setup

Lecture 16 Writing a First Test

Lecture 17 Running Tests

Lecture 18 Why Are We Testing?

Lecture 19 The AAA Pattern – Arrange, Act, Assert

Lecture 20 Keep Your Tests Simple!

Lecture 21 Defining Behaviors & Fixing Errors In Your Code

Lecture 22 Demo: Writing More Tests

Lecture 23 Testing For Errors

Lecture 24 Demo: Adding More Tests

Lecture 25 Testing For Thrown Errors & Error Messages

Lecture 26 Exercise: Problem

Lecture 27 Exercise: Solution

Lecture 28 Tests With Multiple Assertions (Multiple Expectations)

Lecture 29 More Practice!

Lecture 30 Introducing Test Suites

Lecture 31 Adding Tests To Frontend & Backend Projects

Lecture 32 Module Summary

Section 4: Writing Good Tests

Lecture 33 Module Introduction

Lecture 34 What To Test & Not To Test

Lecture 35 Writing Good Tests – An Overview & Summary

Lecture 36 Only Test “One Thing”

Lecture 37 Splitting Functions For Easier Testing & Better Code

Lecture 38 Refactoring Code

Lecture 39 Formulating Different Expectations

Lecture 40 A Word About Code Coverage

Lecture 41 Module Summary

Section 5: Integration Tests

Lecture 42 Module Introduction

Lecture 43 Introducing Integration Tests

Lecture 44 Writing an Integration Test & Reasoning

Lecture 45 Testing For Errors

Lecture 46 Integration vs Unit Tests: Finding the Right Balance

Section 6: Advanced Testing Concepts

Lecture 47 Module Introduction

Lecture 48 toBe() vs toEqual()

Lecture 49 The Problem With Asynchronous Code

Lecture 50 Testing Asynchronous Code With Callbacks

Lecture 51 Testing Asynchronous Code With Promises & async / await

Lecture 52 Returning Promises In Tests

Lecture 53 Getting Started with “Testing Hooks”

Lecture 54 Why Hooks?

Lecture 55 Using Testing Hooks (beforeEach, beforeAll, afterEach, afterAll)

Lecture 56 Concurrent Tests

Lecture 57 Concurrency & Default Behavior

Lecture 58 Module Summary

Section 7: Mocking & Spies: Dealing with Side Effects

Lecture 59 Module Introduction

Lecture 60 The Starting Project

Lecture 61 The Problem With Side Effects & Tests

Lecture 62 Introducing Spies & Mocks

Lecture 63 Working with Spies

Lecture 64 Getting Started with Mocks & Automocking

Lecture 65 Note on Mocking

Lecture 66 Notes on Spies

Lecture 67 Custom Mocking Logic

Lecture 68 Managing Custom Mock Implementations Globally (__mocks__ Folder)

Lecture 69 More Mocking Functionalities

Lecture 70 Module Summary

Section 8: More on Mocking & Diving Deeper

Lecture 71 Module Introduction

Lecture 72 The Starting Project

Lecture 73 Refresher: Practicing Basic Tests (1)

Lecture 74 Refresher: Practicing Basic Tests (2)

Lecture 75 Reasons to Mock

Lecture 76 Mocking Global Values & Functions

Lecture 77 Mocking Frontend Libraries

Lecture 78 Test-specific Mocking Logic

Lecture 79 Mocking In Selected Places

Lecture 80 Using Local Mock Values

Lecture 81 Module Summary

Section 9: Testing & The DOM (Frontend JavaScript Testing)

Lecture 82 Module Introduction

Lecture 83 Understanding the Problem

Lecture 84 Working with Different Testing Environments

Lecture 85 Setting up a Virtual HTML Page

Lecture 86 Testing DOM Functionalities

Lecture 87 DOM Tests & Cleanup Work

Lecture 88 Finishing Example

Lecture 89 A Brief Look at the “Testing Library” Package

Lecture 90 Module Summary

Section 10: Course Roundup

Lecture 91 Course Roundup

Lecture 92 Bonus Lecture

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

Course Information:

Udemy | English | 5h 36m | 2.23 GB
Created by: Academind by Maximilian Schwarzmüller

You Can See More Courses in the Developer >> Greetings from CourseDown.com

New Courses

Scroll to Top