The environment
A template-cloned database, factories and a standing
Every check the Data layer ships works unchanged here, because they ask the data boundary directly rather than through a mock of it.
const env = await createTestEnv({ schema })
const orders = env.as(alice).service('orders')
await orders.create({ total: 5 })
Replaces
supertest + a pile of mockstestcontainers
Who is calling
env.as(user) binds the principal into every call
With no principal you get STRANGER, which is what an unauthenticated caller actually is — so the unhappy path is the default rather than something you remember to test.
Replaces
a fake JWT per test
Announcements
env.announced() — what the act broadcast
A mutation that should have announced and did not is invisible to an assertion on the response, and it is exactly what breaks a live client.
Replaces
spying on the socket
Transport parity
The same call down HTTP and WS, compared
Two real transports grading each other. A service that behaves differently depending on how it was reached is a bug no single-transport suite can see.
Replaces
Nothing — there is no common equivalent to swap out.
A real port
Asked for as zero and read back
For the tests that need an origin — a browser, a webhook, a redirect — without hard-coding a number that collides with the app you left running.
Replaces
a port constant per suite
Where it sits
Above the API, and imported by nothing
Which is the whole reason it is a separate package: the Data layer’s own test environment cannot mount an app without importing the API layer, and that would invert the dependency direction.
Replaces
Nothing — there is no common equivalent to swap out.