Fullstack CourseLearn by building
Back to week 4

Topic

Nest testing (unit + e2e / Supertest)

Definition

Nest testing uses @nestjs/testing to build isolated module fixtures for unit tests and often Supertest against a bootstrapped Nest app for HTTP e2e contract checks.

In simpler words

You test providers in isolation, and you test routes by sending real HTTP into a test app.

Before shipping milestone P4, learn how graders and CI assert HTTP behavior without clicking a UI.

After this you can

  • Explain TestingModule vs a full NestFactory bootstrap
  • Describe what Supertest asserts (status + body shape)
  • Run pnpm course:validate-milestone and interpret pass/fail lines

What the course grader does

Definition

This course’s Notes milestones are graded by @repo/notes-milestones, a read-only package that inspects apps/notes-practice source for required contracts.

In simpler words

Treat the grader like CI: implement until green, do not edit the grader.

Official Nest chapter: https://docs.nestjs.com/fundamentals/testing

Local command: pnpm course:validate-milestone be-notes-p4

On success the CLI completes the milestone topic on the course API.

Validate one milestone

pnpm course:validate-milestone be-notes-p1
# ✓ be-notes-p1 (13/13)

Failed checks list the missing file or pattern so you know what to implement next.

Keep in mind

  • Never “fix” a failing milestone by weakening the grader package.
  • Pair Nest testing docs with the P4 ship checklist.

Test

Check your understanding

At least 10 questions — mix of concept, syntax, practical, and logic. Score ≥ 80% (enforced by the API) to save progress.

Checking your session…

10 questions · concept 3 · syntax 3 · practical 2 · logic 2

Concept1. Hands-on: which statement is correct about Nest testing in this course?
Syntax2. Hands-on: which implementation matches Nest testing in this course?
Practical3. Hands-on scenario for Nest testing in this course — what should you do?
Logic4. Hands-on: which reasoning about Nest testing in this course holds up in production?
Concept5. Hands-on: which statement is correct about Nest testing in this course?
Syntax6. Hands-on: which implementation matches Nest testing in this course?
Practical7. Hands-on scenario for Nest testing in this course — what should you do?
Logic8. Hands-on: which reasoning about Nest testing in this course holds up in production?
Concept9. Hands-on: which statement is correct about Nest testing in this course?
Syntax10. Hands-on: which implementation matches Nest testing in this course?