zena:test

zena
import {…} from 'zena:test';

Classes

TestContext

zena
class TestContext

Test context passed to each test function

Constructors
zena
new(name: String)
#
Properties
zena
name: String
#

TestResult

zena
class TestResult

Result of a single test execution

Constructors
zena
new()
#
Properties
zena
name: String
#
zena
passed: boolean
#
zena
error: String | null
#

SuiteResult

zena
class SuiteResult
Constructors
zena
new()
#
Properties
zena
name: String
#
zena
tests
#
zena
suites
#
zena
var passed
#
zena
var failed
#
Methods
zena
addTestResult(result: TestResult): void
#
zena
addSuiteResult(result: SuiteResult): void
#

Suite

zena
class Suite

A test suite containing tests and nested suites

Constructors
zena
new()
#
Properties
zena
name: String
#
zena
tests
#
zena
suites
#
zena
var hasOnly
#
Methods
zena
run(): SuiteResult
#

Functions

test

zena
function test(name: String, fn: (ctx: TestContext) => void): void

Register a test in the current suite

testOnly

zena
function testOnly(name: String, fn: (ctx: TestContext) => void): void

Register a test that will be the only one to run (for debugging)

testSkip

zena
function testSkip(name: String, fn: (ctx: TestContext) => void): void

Register a test that will be skipped

suite

zena
function suite(name: String, fn: () => void): Suite

Create a test suite

runAndReport

zena
function runAndReport(s: Suite, write: (s: String) => void): i32

Run a suite, print results, and return the number of failures. This is the standard entry point for test runners.

Usage in a test wrapper: import { tests } from './my_test.zena'; import { runAndReport } from 'zena:test'; export let main = (): i32 => runAndReport(tests, console.log);