Programming · Intermediate
Testing JavaScript
The habit that separates code you can change from code you are afraid of.
- Lessons
- 15 lessons
- Total runtime
- 14 hours of video
- Modules
- 5 modules
- Optional lessons
- 13 optional
Free. No account.

About this course
Nobody's first project has tests, and that is fine. The trouble starts later, when a codebase gets large enough that you cannot hold it in your head, and every change carries a small chance of breaking something you have forgotten about. At that point you either write tests or you slow down permanently, because the only alternative is checking everything by hand forever.
The useful framing is not "tests prove the code is correct" — they do not. It is that tests let you change code without fear. A suite that runs in ten seconds turns a risky refactor into a routine one, and that single fact is why testing survives as a practice despite everyone finding it tedious.
This course teaches the mechanics with Jest, and the mechanics are genuinely simple: call a function, assert what it returned. The hard part is judgement — what is worth testing, what is a waste of time, and how to write a test that fails for the right reason. Traversy's longer course is where that judgement gets discussed, which is why it is here alongside the quick introduction.
Under three hours required, and around fourteen with the optional lessons — component testing, end-to-end testing with Playwright, and two more passes over Jest. Test something you have already written rather than following along on a toy example; the whole skill is deciding what deserves a test.
What you'll be able to do
- Write and run unit tests with Jest
- Structure a test so its failure tells you what broke
- Mock a dependency, and know why over-mocking makes a suite worthless
- Test asynchronous code without flakiness
- Judge what is worth testing rather than chasing a coverage number
Curriculum
15 lessons · 14 hours
The Mechanics
5 lessons · 3h 25m
- 01CompletedIntroduction To Testing In JavaScript With JestWeb Dev SimplifiedVideoInstalling Jest and writing a first test. The mechanics are genuinely this simple, which is worth seeing early — most of the resistance to testing is imagined complexity.25m
- 02CompletedJavaScript Unit Testing Tutorial for BeginnersOptionalProgramming with MoshVideoStronger than most on the part that matters — what makes a test worth writing, and how to structure one so it fails usefully rather than just fails.49m
- 03CompletedJest Crash CourseOptionalTraversy MediaVideoMocking, async tests and coverage, which is where the first tutorial usually stops. Take it when your tests start needing a database or a network call.57m
- 04CompletedJavaScript Testing with Jest — Crash CourseOptionalfreeCodeCamp.orgVideoA third pass over the same tool. Here because assertion syntax is the sort of thing that only sticks on repetition.1h 1m
- 05CompletedWhy Vitest Is Better Than JestOptionalWeb Dev SimplifiedVideoMost new projects reach for Vitest instead of Jest now. The APIs are near-identical, so this is thirteen minutes of context rather than a whole new tool to learn.13m
The Judgement
1 lesson · 2h 10m
Test-Driven Development
2 lessons · 52m
- 07CompletedTest-Driven Development — A Fun IntroductionOptionalFireshipVideoWriting the test first sounds backwards until you have watched somebody do it once. Thirteen minutes, and the fastest way to understand what the argument is about.13m
- 08CompletedImplementing Linked Lists With Test-Driven DevelopmentOptionalWeb Dev SimplifiedVideoTDD done properly on a non-trivial problem, unedited, including the parts where the design changes because a test was awkward to write. That is the actual benefit being demonstrated.39m
Testing Components
4 lessons · 4h 21m
- 09CompletedReact Testing for BeginnersOptionalProgramming with MoshVideoTesting a user interface is a different problem from testing a function, and the main lesson is to assert on what a user would see rather than on internal state. This teaches that properly.1h 17m
- 10CompletedTesting In React — Jest and React Testing LibraryOptionalPedroTechVideoA short, concrete introduction to the query API — getByRole, getByText and friends — which is most of what you type when testing components.21m
- 11CompletedReact Vite Testing Tutorial — Vitest Crash CourseOptionalPedroTechVideoThe same work set up with Vitest, which is what a Vite project gets by default. Useful if the Jest configuration in the other lessons does not match your project.39m
- 12CompletedReact Testing Course — Code and Test 3 AppsOptionalfreeCodeCamp.orgVideoThree applications tested end to end, so you see the same decisions made repeatedly. The longest item here and the best for building judgement rather than syntax.2h 4m
End-to-End Testing
3 lessons · 2h 58m
- 13CompletedSoftware Testing Course — Playwright and E2EOptionalfreeCodeCamp.orgVideoUnit tests cannot tell you whether the sign-up form works. This drives a real browser through a real application, which is the only kind of test that answers that question.1h 4m
- 14CompletedReact Testing with PlaywrightOptionalCosden SolutionsVideoPlaywright applied to a React app specifically, including how to keep the tests from becoming slow and flaky — which is why most teams abandon end-to-end testing.33m
- 15CompletedIntroduction to Playwright with Debbie O'BrienOptionalThis Dot MediaVideoFrom someone on the Playwright team, covering the tooling around the tests — the trace viewer, debugging a failure, and running against several browsers.1h 21m
Credits
Every lesson in this course was made by one of these channels. Tubeversity sequenced them; it did not make them. If a course is useful to you, the people below are the ones who earned it.