Skip to content

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.

Add a test script to package.json:

package.json (excerpt)
{
"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:

tsconfig.json (excerpt)
{
"compilerOptions": {
"allowImportingTsExtensions": true
}
}
src/greet/greeting.test.ts
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:

Terminal window
npm test
npm run build # also type-checks the whole project
node scripts/check-artifact.mjs # validates the build without uploading

See Validate in CI for the script.

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.