メインコンテンツへスキップ
Academind
すべてのコース

Academind Proのコース

JavaScript Unit Testing - The Practical Guide

Learn how to write automated tests (unit & integration tests) for your JavaScript projects with Vitest & Jest.

  • 10セクション · 92件のレクチャー
  • 合計5 時間 38 分
JavaScript Unit Testing - The Practical Guide

このコースについて

You can write JavaScript that works — but the moment you change something, you’re never 100% sure what you just broke. And when testing feels intimidating, it’s easy to keep shipping without the safety net you know you should have.

This course gives you a practical, step-by-step way into automated testing without drowning you in theory. You’ll work with real examples, see typical testing problems defined clearly, and then solve them with repeatable strategies you can bring into any codebase.

By the end, you’ll be able to add reliable unit and integration tests to your own projects, choose what’s worth testing (and what isn’t), and keep tests stable even when your code interacts with the outside world. Whether you’re working on NodeJS or frontend code, you’ll leave with a workflow you can apply immediately.

学べること

You’ll build a testing workflow around Vitest (with Jest-compatible patterns) that you can reuse across NodeJS and frontend JavaScript projects.

  1. 01

    Structure unit tests

    You’ll be able to write unit tests that are easy to read and maintain, using clear patterns for arranging test code and keeping each test focused on one behavior.

  2. 02

    Add integration coverage

    You’ll be able to move beyond isolated units and create integration tests that verify multiple pieces working together, so you can catch issues that only appear when code is combined.

  3. 03

    Mock side effects

    You’ll be able to remove side effects from tests by using mocks, so your test suite stays deterministic even when your code would normally touch external dependencies.

  4. 04

    Use spies effectively

    You’ll be able to work with spies to observe calls and interactions, letting you verify how your code behaves without rewriting the production logic just to make it testable.

  5. 05

    Write strong assertions

    You’ll be able to formulate precise expectations (assertions) that prove the right outcomes, instead of tests that pass for the wrong reasons or fail with unclear messages.

  6. 06

    Test async and sync code

    You’ll be able to test both synchronous and asynchronous JavaScript reliably, so promises, timers, and async flows don’t turn your test suite into a flaky guessing game.

前提条件

  • Basic JavaScript knowledge is required.

  • No prior testing knowledge is necessary.

このコースの対象者

  • JavaScript developers

    You’re building projects in JavaScript and want the confidence of automated tests, but you’re not sure how to start or how to structure tests that stay maintainable.

  • Testing-avoidant developers

    You’ve always found automated testing intimidating, so you’ve postponed it — this course gives you a clear, practical path that makes testing feel approachable.

  • Frontend or NodeJS builders

    You work on frontend code or NodeJS code and want a testing foundation that isn’t tied to one framework, so you can apply it across different kinds of projects.

カリキュラム

始める前に、このコースの構成とペースをご確認ください。

  1. 1Getting Started8件のレクチャー · 24 分
    1. 01Welcome To This Course!0:54分
    2. 02What Is Testing?4:41分
    3. 03Unit Testing: What & Why?4:33分
    4. 04Unit vs Integration vs E2E Tests5:51分
    5. 05A Quick Note About Test-Driven Development (TDD)1:35分
    6. 06About This Course6:42分
    7. 07Join Our Learning Community0:00分
    8. 08Course Resources & Project Snapshots0:00分
  2. 2Setup & Testing Software5件のレクチャー · 24 分
    1. 01Module Introduction1:09分
    2. 02Which Tools Are Needed For Testing?6:27分
    3. 03Jest & Vitest6:56分
    4. 04Installing Vitest1:36分
    5. 05Course Project Setup7:59分
  3. 3Testing Basics19件のレクチャー · 1 時間 19 分
    1. 01Module Introduction1:20分
    2. 02Basic Test File & Project Setup7:04分
    3. 03Writing a First Test6:54分
    4. 04Running Tests4:18分
    5. 05Why Are We Testing?3:02分
    6. 06The AAA Pattern - Arrange, Act, Assert4:36分
    7. 07Keep Your Tests Simple!1:34分
    8. 08Defining Behaviors & Fixing Errors In Your Code7:38分
    9. 09Demo: Writing More Tests4:37分
    10. 10Testing For Errors4:14分
    11. 11Demo: Adding More Tests3:29分
    12. 12Testing For Thrown Errors & Error Messages4:59分
    13. 13Exercise: Problem1:44分
    14. 14Exercise: Solution4:47分
    15. 15Tests With Multiple Assertions (Multiple Expectations)5:18分
    16. 16More Practice!2:55分
    17. 17Introducing Test Suites4:39分
    18. 18Adding Tests To Frontend & Backend Projects3:36分
    19. 19Module Summary2:22分
  4. 4Writing Good Tests9件のレクチャー · 37 分
    1. 01Module Introduction1:25分
    2. 02What To Test & Not To Test6:04分
    3. 03Writing Good Tests - An Overview & Summary4:36分
    4. 04Only Test "One Thing"2:02分
    5. 05Splitting Functions For Easier Testing & Better Code5:01分
    6. 06Refactoring Code10:13分
    7. 07Formulating Different Expectations6:07分
    8. 08A Word About Code Coverage0:00分
    9. 09Module Summary2:01分
  5. 5Integration Tests5件のレクチャー · 15 分
    1. 01Module Introduction0:57分
    2. 02Introducing Integration Tests2:23分
    3. 03Writing an Integration Test & Reasoning5:51分
    4. 04Testing For Errors2:28分
    5. 05Integration vs Unit Tests: Finding the Right Balance3:25分
  6. 6Advanced Testing Concepts12件のレクチャー · 38 分
    1. 01Module Introduction1:06分
    2. 02toBe() vs toEqual()4:21分
    3. 03The Problem With Asynchronous Code6:13分
    4. 04Testing Asynchronous Code With Callbacks5:02分
    5. 05Testing Asynchronous Code With Promises & async / await4:32分
    6. 06Returning Promises In Tests0:00分
    7. 07Getting Started with "Testing Hooks"1:42分
    8. 08Why Hooks?4:39分
    9. 09Using Testing Hooks (beforeEach, beforeAll, afterEach, afterAll)6:13分
    10. 10Concurrent Tests2:14分
    11. 11Concurrency & Default Behavior0:00分
    12. 12Module Summary1:48分
  7. 7Mocking & Spies: Dealing with Side Effects12件のレクチャー · 45 分
    1. 01Module Introduction1:03分
    2. 02The Starting Project4:11分
    3. 03The Problem With Side Effects & Tests6:24分
    4. 04Introducing Spies & Mocks2:07分
    5. 05Working with Spies5:13分
    6. 06Getting Started with Mocks & Automocking5:18分
    7. 07Note on Mocking2:18分
    8. 08Notes on Spies1:30分
    9. 09Custom Mocking Logic7:51分
    10. 10Managing Custom Mock Implementations Globally (__mocks__ Folder)6:11分
    11. 11More Mocking Functionalities1:34分
    12. 12Module Summary1:00分
  8. 8More on Mocking & Diving Deeper11件のレクチャー · 46 分
    1. 01Module Introduction1:04分
    2. 02The Starting Project3:02分
    3. 03Refresher: Practicing Basic Tests (1)6:25分
    4. 04Refresher: Practicing Basic Tests (2)4:43分
    5. 05Reasons to Mock2:11分
    6. 06Mocking Global Values & Functions8:13分
    7. 07Mocking Frontend Libraries0:00分
    8. 08Test-specific Mocking Logic6:59分
    9. 09Mocking In Selected Places5:21分
    10. 10Using Local Mock Values7:01分
    11. 11Module Summary1:16分
  9. 9Testing & The DOM (Frontend JavaScript Testing)9件のレクチャー · 25 分
    1. 01Module Introduction1:14分
    2. 02Understanding the Problem3:58分
    3. 03Working with Different Testing Environments3:42分
    4. 04Setting up a Virtual HTML Page5:05分
    5. 05Testing DOM Functionalities2:58分
    6. 06DOM Tests & Cleanup Work3:12分
    7. 07Finishing Example1:32分
    8. 08A Brief Look at the "Testing Library" Package1:53分
    9. 09Module Summary1:08分
  10. 10Course Roundup2件のレクチャー · 4 分
    1. 01Course Roundup4:10分
    2. 02Bonus: More Courses & Content0:00分

始める準備はできましたか?

このコースをAcademind Proで購入するか、Academind InfiniteのAll Accessですべてのコースを利用しましょう。

ブラックフライデー: All Access 1年分が $249 $249 · までの限定価格セール価格で購入する
  • Academind Proでこのコースを購入

    $69買い切り

    税込 · 30日間返金保証

    • このコースへの無期限アクセス
    • このコースの今後のアップデートすべて
    • ダウンロード資料、コード、修了証
    JS Unit Testingを購入
  • Academind InfiniteのAll Access

    $25/月

    または$249 $249 /年17%お得

    • すべてのコースを、すべての機能付きで
    • 新しいコースも随時追加
    • チューター(すべての機能)
    All Accessを始める

All Accessには、Academind Proのすべてのコースも含まれます。

Academind ProとAcademind Infinite

コースもログインもそれぞれ別の、2つのプラットフォームです。

Academind Pro

pro.academind.comにある、これまでのコースプラットフォームです。Proのサブスクリプションとご購入のコースは、引き続きProでご利用いただけます。

Academind Proにログイン

Academind Infinite

AIファーストの新しいプラットフォームです。ProメンバーはProのアカウントでログインできます。Pro All AccessにはInfiniteも含まれ、すべてのコースを受講できます。

Academind Infiniteにログイン

Proのアカウントをお持ちか、Proでコースをご購入済みですか?

Infiniteに移ったのは、Proのコースの一部だけです。お持ちのコースを選んで、Infiniteでのページを開いてください。