Skip to content

Scenario tests

A file in tests/ walks the whole Startup in the test environment, as a buyer would, before a Change merges.

A file in tests/ walks the whole Startup in the test environment, as a buyer would: sign up, pay, use, renew.

  • tests/
  • first-renewal.test.ts

Reference

TypeScript with startup-builder/test.

ExportTypeHolds
walk(persona)functionA synthetic buyer that drives every Interface
clock.advance(duration)functionMoves the test clock; everything due in between fires in order
test, expectfunctionCases and assertions

Examples

Minimal

tests/first-renewal.test.ts
import { expect, test, walk } from 'startup-builder/test'

test('a manager can subscribe', async () => {
  const manager = await walk('manager')
  expect(await manager.subscribe('pro')).toBeTruthy()
})

Leaseline

tests/first-renewal.test.ts
import { clock, expect, test, walk } from 'startup-builder/test'

test('a lease ending in 60 days gets its notice', async () => {
  const manager = await walk('manager')
  await manager.subscribe('pro')
  await manager.import('mappings/rent-roll', 'fixtures/rent-roll.csv')
  await clock.advance('1 day')
  expect(await manager.inbox()).toContainMessage('Your lease at 4B ends')
})

What it builds

The StartupBuilder runs every scenario on each Change's preview.

  • a check result per scenario; Change.merge refuses while one fails
  • no live money and no live Messages: the test environment fakes Stripe and mail

Good to know

  • The same clock moves from the CLI: npx startup-builder clock advance --by 30d.