Checking your own application
A fragment is data, so testing one needs no browser, no server and no snapshot to keep in sync.
weft verify --probe walks the whole tree, each tier answering for its own registry, and exits 0.
And W_REGION_TREE_DEEPER when a route turns out to cross more boundaries than its plan could count.
In plain terms
You can ask a running deployment what it is actually serving, and it will disagree out loud. Conformance runs as plain node --test over the packages and your own application, with no test framework to install.
A fragment compiles to data, and data is the easiest thing there is to test. There is no browser to start, no server to boot for a unit test, and no snapshot file to keep in step — because the thing under test is a sealed template and its render is a pure function of values.
Render one
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { createApp } from '@weftjs/core/server'
import { fragmentIR } from '@weftjs/core'
import { render } from '@weftjs/ir'
test('the badge renders its label', async () => {
await createApp(process.cwd(), { mode: 'dev', port: 0 })
const badge = fragmentIR('examples/badge')
const html = new TextDecoder().decode(render(badge.entry, { label: 'new' }, badge.resolve))
assert.match(html, /new/)
})fragmentIR hands back the same sealed template the server renders, so a test is not a second compilation that could disagree with production. This site’s own tests are that shape, and they are the reason a broken example cannot ship.
Assert on what the compiler inferred
The interesting assertions are usually not about markup. A fragment’s effect set, its hole classes and its wire forms are all on the template, so the properties this framework cares about are directly checkable:
assert.deepEqual(cart.entry.effects.reads, ['identity', 'cookie:currency'])
assert.equal(total.entry.holes[1]?.escape, 'proven-safe')
assert.ok(feed.entry.forms.includes('delta'))A test that a private fragment stayed private is one line, and it fails the moment somebody adds a read that would have made a page uncacheable.
Serve the whole thing
const app = await createApp(root, { mode: 'dev', port: 0 })
const serving = await serveApp(app)
const response = await fetch(new URL('/cart', serving.url))
assert.equal(response.headers.get('vary'), 'Cookie')
await serving.close()Port zero, so tests run in parallel. What is worth asserting at this level is the envelope — the status, the cache class, Vary, the order the regions arrived in — because those are the things a unit test on a template cannot see.
Three things the framework checks for you
| Command | What it refuses |
|---|---|
weft build | A fragment outside the subset, a declaration contradicting an inferred fact, a hole nothing fills, a route two files both mean. |
weft verify | A composed region whose contract has moved since this build. |
weft why <route> | Nothing — it prints the plan and where each fact came from. The first thing to run when a page is not what you expected. |