Implement solve(plan) where plan is a serialised test suite:
{
suites: [
{
name: 'Math',
beforeEach: 'counter++', // JS expression appended to a harness
afterEach: null,
tests: [
{ name: 'adds', body: 'return counter === 1' },
{ name: 'still increments', body: 'return counter === 2' },
],
}
]
}Each beforeEach / afterEach / test body is a JS statement string
executed with new Function against a shared mutable context object{ counter: 0 } that is reset to {} before each suite.
A test passes if its body returns true. Any other return value or a
thrown error means failure.
Return:
{
passed: number, // count of passing tests
failed: number, // count of failing tests
results: [
{ suite: string, test: string, pass: boolean, error: string | null }
]
}Rules:
beforeEach runs before every test in the suite (including after failures).afterEach runs after every test, even if the test threw.beforeEach throws, the test is marked failed with the error message; afterEach still runs.null means the hook is absent.Sample tests