Concept
An integration test starts the real server against a real database and sends HTTP requests, checking status, body and side effects. It is slower than a unit test and catches what unit tests cannot.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show Integration tests doing its job.
import { test, before, after } from "node:test";
import assert from "node:assert/strict";
import { build } from "../src/app.js";
let app;
before(async () => { app = await build({ databaseUrl: process.env.TEST_DATABASE_URL }); });
after(() => app.close());
test("creates an order", async () => {
const res = await app.inject({ method: "POST", url: "/api/v1/orders",
payload: { items: [{ sku: "A1", quantity: 2 }] } });
assert.equal(res.statusCode, 201);
assert.match(res.headers.location, /\/orders\//);
});Tests that depend on data left by earlier tests. They pass in one order and fail in another; each test should create what it needs and the database should be reset between them.
Your roadmap puts these before Integration tests, unless you already know them.
Once a session shows you understand Integration tests, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.
Topics that build on Integration tests.