Production Mado 0.15.3
Testing
Mado projects are plain TypeScript and browser APIs, so tests should stay plain
too. The framework repository uses Node's built-in test runner plus linkedom
for DOM tests.
Commands
npm run typecheck
npm run build
npm test
Before publishing or merging a release branch, run all three.
Unit tests with DOM
import test from "node:test";
import assert from "node:assert/strict";
const { parseHTML } = await import("linkedom");
const { window } = parseHTML("<!doctype html><html><body></body></html>");
globalThis.window = window;
globalThis.document = window.document;
globalThis.Node = window.Node;
globalThis.HTMLElement = window.HTMLElement;
const { html, render } = await import("../dist/src/html/template.js");
test("renders a value", () => {
const root = document.createElement("div");
render(html`<p>${"hello"}</p>`, root);
assert.equal(root.querySelector("p").textContent, "hello");
});
Build first, then import from dist/. This tests the same files the browser
will load.
What to cover
Test behavior, not internal implementation details:
- signal/computed scheduling and cleanup;
- template binding edges: child values, attributes, events, directives;
- route guards, redirects, scroll/focus behavior, error boundaries;
- forms: validation, async validation races and native controls added or removed dynamically;
- resources/mutations: cache keys, invalidation, lifecycle cleanup;
- CLI flows:
mado release,mado static,mado preview.
Browser smoke tests
Use Playwright or another browser runner for flows that require real layout, focus, navigation or custom-element lifecycle. Keep them small:
- start the app;
- visit one route;
- click one link or submit one form;
- assert the user-visible result.
Most regression tests should still be fast Node tests.
Test data
Keep API data in local fixtures or tiny in-memory fake clients. Do not call real
services from framework tests. For app tests, make the API client injectable via
createContext() so pages can run against a fake client.
Release checklist
npm run typecheck
npm run build
npm test
npm run verify:release
In an application, mado release runs typecheck, Vite build,
static-snapshot capture, compression and deployment-file generation. In the
framework repository, npm run verify:release is the maintainer gate: tests,
documentation/API checks, size report, packed-package starter smoke and audit.
Set MADO_REQUIRE_BROWSER=1 after installing the pinned Playwright Chromium
to make browser availability strict.