Udemy
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
pytest & Vitest: 100 Unit Test Drills – Python & TypeScript
6 students

pytest & Vitest: 100 Unit Test Drills – Python & TypeScript

Testing transcends language. 100drills in pytest & Vitest: mocks, async, DB, HTTP, coverage & CI, side by side. No setup
Created byM Sakai
Last updated 10/2026
English

What you'll learn

  • Understand the execution models of pytest and Vitest, and explain how tests run with near-zero configuration in both Python and TypeScript.
  • Design clear assertions in two languages—equality (`==`/`is` vs `toBe`/`toEqual`/`toStrictEqual`), exceptions, asymmetric matchers, and custom assertions.
  • Master data-driven tests with `parametrize` (pytest) and `each`/`for` (Vitest): Cartesian products and readable test IDs as a shared concept across languages.
  • Design scope and dependency graphs with fixtures (`@fixture` in pytest, `test.extend` in Vitest), balancing heavy initialization sharing with test isolation.
  • Handle mock three-layer reset (clear/reset/restore), module mock hoisting, env/time stubs, and fake timers in both `monkeypatch`/`mocker` and `vi.mock`/`vi.fn`.
  • Use `pytest-asyncio` and Vitest async tests with `resolves`/`rejects`, fake timers, polling, and AsyncMock to verify async logic deterministically
  • Verify temp-file I/O, in-memory SQLite, and HTTP APIs (FastAPI + TestClient / Hono + zod) with "real I/O but fast" integration tests, swapping mocks via DI.
  • Grasp the full picture of test operations across two languages: snapshots, coverage threshold gates, unit/integration separation, spec-first TDD, and pseudo-CI.

Course content

25 sections • 205 lectures • 16h 47m total length
  • Course Overview11:12
  • How the Course Is Conducted8:26
  • Cloud Shell: Getting Started, Saving and Limits1:28
  • pytest: Exercise Materials and Cloud Shell Setup3:24
  • Vitest: Exercise Materials and Cloud Shell Setup3:46

Requirements

  • Ability to read and write basic syntax (variables, functions, classes, `import`, `async`/`await`) in either Python or TypeScript/JavaScript. No need for both.
  • A PC, browser and Google account with verified age 18 or above. Upload the provided ZIP and run its setup script in Google Cloud Shell. Free allowance: 50 hours/week, 5 GB home. Local Python 3.12+ and Node.js 24 are alternatives.
  • No testing experience required. Even if you've never written a test, each track starts from `add(2, 3)` and builds up step by step.

Description

This course contains the use of artificial intelligence.

"You have to relearn testing for every language"—this course shatters that assumption.

The real reason developers struggle with automated testing is that they rely on rote memorization of framework APIs. Mocks that don't take effect, Promises or async that won't resolve with fake timers, mocks leaking into the next test—these problems stem from exactly the same misunderstanding of mechanisms in both `pytest` and `Vitest`. Conversely, once you grasp those mechanisms, you'll be able to diagnose the cause the moment you see an error message, regardless of the language.

This course consists of 100 hands-on exercises: 50 for pytest (Python) and 50 for Vitest (TypeScript). These two sets of 50 are not a random collection. They follow the same roadmap in parallel across two languages: "first assert → equality and exceptions → parametrize/each → fixtures → mock three-layer reset → async and fake timers → files and in-memory SQLite → HTTP API (FastAPI / Hono) → snapshots → coverage thresholds, TDD, and pseudo-CI." A concept you understand in one language instantly clicks as a "dialect" in the other—this back-and-forth cultivates a "test design ability" that memorization alone can never achieve.

You can start from either side. Python developers can begin with the pytest track and discover "So this is how JavaScript mocks work" in the Vitest track. Frontend/Node.js developers can start with the Vitest track and confirm "The fixture design philosophy is the same" in the pytest track. By the time you've completed both, you're no longer just a user of a specific framework—you've become someone who understands the discipline of testing itself.

The content goes well beyond basics. Both tracks cover: temporary file I/O, the repository pattern with in-memory SQLite, HTTP API testing (FastAPI + TestClient on the Python side, Hono + zod on the TypeScript side), swapping mocks via dependency injection, snapshots, coverage threshold gates, and building TDD and pseudo-CI from specifications—all practical material you can take straight to production.

Learn in your browser using Google Cloud Shell. Upload the supplied ZIP and run its setup script; no local Python or Node.js installation is needed. A Google account with verified age 18 or above is required. The free allowance is 50 hours per week and 5 GB home storage. The home directory may be deleted after 120 days of inactivity, so download backups. Local Python 3.12 or newer and Node.js 24 are alternatives. Follow the new opening material guides in place of the CodeSandbox steps in the videos.

Not just learning to write tests, but learning to design tests across languages—that is the goal of this course.

Who this course is for:

  • Full-stack-minded engineers who use (or plan to use) both Python and TypeScript and want to systematically master testing in both languages in a single course.
  • Engineers who can write tests in one language but freeze up in the other. Ideal for pytest users entering Vitest, and vice versa.
  • JavaScript/TypeScript and Python developers who have relied on memorization for testing and want to re-learn from the ground up how and why tests work.
  • Beginners to intermediate learners who want to start automated testing without setup headaches. Work through all 100 drills hands-on, right in your browser.
  • Tech leads and team leaders who want to introduce a "test design framework" that works across languages, including coverage thresholds and CI pipelines.