Skip to main content
CF

Mastering JavaScript Unit Testing

3h 51m 31s
English
Free

A comprehensive, beginner-friendly guide covering everything from the basics to advanced techniques. Tired of piecing together disconnected tutorials or dealing with rambling, confusing instructors? This course is for you! It's perfectly structured into a series of bite-sized, easy-to-follow videos that cover both theory and practice.

  1. Explore the fundamentals of unit testing and its benefits.
  2. Master core unit testing techniques and best practices.
  3. Craft maintainable, robust, and trustworthy tests that deliver value.
  4. Learn to execute and navigate tests effectively in VSCode.
  5. Perform positive, negative, and boundary testing for comprehensive coverage.
  6. Evaluate code coverage to ensure comprehensive testing.
  7. Create parameterized tests for versatile testing scenarios.
  8. Isolate code with mocks and learn when to use them.
  9. Spy on functions to gain insights into their behavior.
  10. Improve code quality using static analysis tools.
  11. Utilize Prettier to format your code consistently.
  12. Implement ESLint to catch code quality issues early.
  13. Prevent type errors in your code using TypeScript.
  14. Automate code quality checks using Husky.

About the Author: Mosh Hamedani (Code with Mosh)

Mosh Hamedani (Code with Mosh) thumbnail

Mosh Hamedani is the founder of Code with Mosh, one of the highest-volume independent online instructors in software education. He has been publishing courses continuously since the early Udemy era and has taught over a million students across his Udemy catalog and his standalone Code with Mosh platform. His teaching style is patient, rigorously structured, and deliberately beginner-tolerant — the courses are widely cited as some of the most accessible introductions to their respective topics.

The Code with Mosh catalog covers an unusually wide span: web development with HTML / CSS / JavaScript / React / Angular / Node.js, Python and Django, C# and .NET, mobile development with React Native and Flutter, SQL and database fundamentals, and the algorithm / data-structure interview prep tracks. Few independent instructors maintain this much breadth at consistent quality.

The CourseFlix listing under this source carries over 35 Code with Mosh courses spanning that range. Material is paid; Code with Mosh runs on per-course pricing on the original platform. Courses are aimed primarily at developers picking up a new technology from a clean start through to working production proficiency.

Watch Online 55 lessons

  • Space or K: play or pause
  • J: rewind 10 seconds
  • L: forward 10 seconds
  • Left Arrow: rewind 5 seconds
  • Right Arrow: forward 5 seconds
  • Up Arrow: volume up
  • Down Arrow: volume down
  • M: mute or unmute
  • F: toggle fullscreen
  • T: toggle theater mode
  • I: toggle mini player
  • 0 to 9: seek to 0 to 90 percent of the video
  • Shift plus N: next video
  • Shift plus P: previous video
0:00 0:00
#Lesson TitleDuration
1Welcome 01:23
2Prerequisites 00:42
3Course Structure 02:16
4How to Take This Course 00:59
5Setting Up the Testing Environment 00:34
6Starter Project 00:55
7Introduction 01:40
8What is Unit Testing 05:22
9Types of Tests 03:15
10Choosing a Testing Framework 01:40
11Setting Up Vitest 01:15
12Writing Your First Tests 09:21
13Exercise: Testing fizzBuzz 05:57
14Test-driven Development 07:11
15Exercise: Testing Factorial 05:02
16Running Tests 04:24
17Navigating Tests in VSCode 04:12
18Code Coverage 04:34
19Introduction 00:55
20Characteristics of Good Unit Tests 04:25
21Using Matchers 03:07
22Writing Good Assertions 07:18
23Exercise: Testing getCoupons 09:01
24Positive and Negative Testing 07:20
25Exercise: Testing validateUserInput 07:19
26Boundary Testing 02:58
27Exercise: Testing isValidUsername 05:46
28Exercise: Testing canDrive 06:36
29Parameterized Tests 04:57
30Exercise: Parameterized Tests 04:21
31Testing Asynchronous Code 04:30
32Setup and Teardown 02:43
33Exercise: Testing a Stack 09:55
34Introduction 00:32
35Creating Mock Functions 05:39
36Exercise: Working with Mock Functions 01:53
37Mocking Modules 05:02
38Exercise: Testing getShippingInfo 05:29
39Interaction Testing 03:24
40Exercise: Testing submitOrder 06:53
41Partial Mocking 07:33
42Spying on Functions 05:38
43Clearing, Resetting, and Restoring Mocks 04:56
44To Mock or Not to Mock 01:16
45Mocking Dates 03:52
46Exercise: Testing getDiscount 01:56
47Introduction 00:34
48What are Static Analysis Tools 01:13
49Formatting Code with Prettier 05:11
50Linting Code with ESLint 09:53
51Catching Type Errors with TypeScript 06:33
52Running ESLint on TypeScript 06:14
53Automating Code Quality Checks with Husky 03:57
54Running Tests on Push 01:34
55Course Wrap Up 00:26

Books

Read Book Mastering JavaScript Unit Testing

#TitleTypeOpen
11- Introduction to Unit Testing PDF
22- Core Unit Testing Techniques PDF
33- Breaking Dependencies with Mocks PDF
44- Improving Code Quality using Static Analysis Tools PDF

Related courses

  • Modern JavaScript From The Beginning 2.0 thumbnailClassic

    Modern JavaScript From The Beginning 2.0

    By: Brad Traversy
    This is a 37+ hour in-depth course that will take you from the absolute beginning of JavaScript, learning about data types, functions and loops to learning DOM
    36h 42m5/5
  • DevOps.js Conference 2021 thumbnailUpdated 3y ago

    DevOps.js Conference 2021

    By: DevOps.js Conference
    DevOps.js is an event for all the developers and architects involved in building infrastructure and setting up pipelines and deployments for JavaScript applicat
    7h 51m
  • Shaders for the Web thumbnailUpdated 3y ago

    Shaders for the Web

    By: SuperHi
    Learn how to make OpenGL shaders using the programming language GLSL, and gain insight on how the top websites use hardware-enabled graphics.
    16h 3m

Frequently asked questions

What prerequisites are needed before taking this course?
The course includes a dedicated lesson on prerequisites. It is designed to be beginner-friendly, so no prior experience with unit testing is required. However, a basic understanding of JavaScript is recommended to follow along effectively with the examples and exercises.
What projects or exercises will I work on during the course?
Throughout the course, you will engage in practical exercises such as testing functions like fizzBuzz, factorial, and more complex scenarios like validateUserInput and getShippingInfo. These exercises help reinforce the concepts of unit testing, test-driven development, and the use of mock functions.
Is this course suitable for experienced developers?
While the course is beginner-friendly, it also covers advanced topics like mocking modules, interaction testing, and parameterized tests, making it suitable for experienced developers looking to deepen their understanding of JavaScript unit testing. Advanced exercises and topics like code coverage and static analysis tools are also included.
What testing framework is used in this course?
The course uses Vitest as the testing framework. Lessons include setting up Vitest, writing initial tests, and using it to handle various testing scenarios such as asynchronous code, mock functions, and parameterized tests.
Does the course cover deployment or integration testing?
This course focuses specifically on unit testing and does not cover deployment or integration testing. It is structured to provide a deep dive into unit testing techniques and tools, such as matchers, mock functions, and code coverage.
How much time should I expect to commit to completing this course?
The course consists of 55 lessons, each in a bite-sized video format. While the total runtime is not specified, the course is designed to be consumed at your own pace. You should allocate time for both watching the videos and performing the exercises to gain the most benefit.
Can the skills learned in this course be applied to other programming languages or frameworks?
The fundamental principles of unit testing taught in this course, such as writing good assertions, using mock functions, and handling asynchronous code, can be applied to other programming languages and frameworks. However, specific tools like Vitest are unique to the JavaScript ecosystem.