Testing
Use the fastest tool that can show that each part works:
| To check | Use |
|---|---|
| Logic, validation, and request handlers | Node.js unit tests |
| How pages look and behave | npm run dev, with the mock API |
| The runtime, tokens, services, the Adapt iframe, webhooks, and resource use | The local emulator |
Coding agents with the Adapt skills follow the same split.
Unit tests
Section titled “Unit tests”Add a test script to package.json:
{ "scripts": { "test": "node --test \"src/**/*.test.ts\"" }}Node.js 24 runs TypeScript tests directly. To import your modules with .ts paths, also add this to the root tsconfig.json, or the build fails:
{ "compilerOptions": { "allowImportingTsExtensions": true }}import { test } from "node:test";import assert from "node:assert/strict";import { greeting } from "./greeting.ts";
test("greets by name", () => { assert.equal(greeting("Ada"), "Hello, Ada!");});Run them with npm test. Some tips:
- Keep validation and other rules in plain modules, without runtime or browser APIs. They are easy to test.
- Test request handlers with a small fake of the SDK’s API.
- Test what the emulator cannot show: parallel sessions, duplicate callbacks, and settings saved by older versions.
Run npm run dev, and check each page in both themes, at narrow and wide sizes, and in each state that the mock can show. See Check your pages.
These steps need no emulator:
npm testnpm run build # also type-checks the whole projectnode scripts/check-artifact.mjs # validates the build without uploadingSee Validate in CI for the script.
Record the results
Section titled “Record the results”Write down what you tested, where, and what you could not test, in your developer notes. Reviewers then know what each release is known to do.