Testing
zune.testing
A library to interact with the testing suite.
Properties
running
Whether the testing suite is running.
running: boolean_failed
[Internal]
The number of tests that have failed.
_failed: number_count
[Internal]
The number of tests conducted.
_count: number_start
[Internal]
The number of tests that have passed.
_start: numberexpectEqual
Expects a value to equal another.
Similar to assert(value == expected, ...)
expectEqual: ((expected: any, value: any) -> ())Functions
test
Conducts a test.
Will be ignored if the testing suite is not running.
test(name: string, callback: () -> (), timeout: number?): ()Parameters
name: string- The name of the test.callback: () -> ()- The callback to run the test.timeout: number?- The timeout on how long a test should last.
describe
Describes a test suite.
Will be ignored if the testing suite is not running.
describe(name: string, callback: () -> ()): ()Parameters
name: string- The name of the suite.callback: () -> ()- The callback to run the suite.
defer
Defers a function.
Deferred function will be executed after a test completes. Useful for cleaning up resources.
defer(fn: () -> ()): ()Parameters
fn: () -> ()
expect
Expects a value.
expect(value: (...any) -> ...any): type ExpectCases = BasicCases & {
never: BasicCases,
}
type BasicCases = {
toBe: (expected: any) -> (),
toBeDefined: () -> (),
toBeCloseTo: (expected: number, precision: number) -> (),
toBeGreaterThan: (expected: number) -> (),
toBeGreaterThanOrEqual: (expected: number) -> (),
toBeLessThan: (expected: number) -> (),
toBeLessThanOrEqual: (expected: number) -> (),
toBeNil: () -> (),
toBeNan: () -> (),
toHaveLength: (expected: number) -> (),
toBeFalsy: () -> (),
toBeTruthy: () -> (),
}
type FunctionalCases = ExpectCases & {
toThrow: (expected: string?) -> (),
never: FunctionalCases,
}FunctionalCasestype ExpectCases = BasicCases & {
never: BasicCases,
}
type BasicCases = {
toBe: (expected: any) -> (),
toBeDefined: () -> (),
toBeCloseTo: (expected: number, precision: number) -> (),
toBeGreaterThan: (expected: number) -> (),
toBeGreaterThanOrEqual: (expected: number) -> (),
toBeLessThan: (expected: number) -> (),
toBeLessThanOrEqual: (expected: number) -> (),
toBeNil: () -> (),
toBeNan: () -> (),
toHaveLength: (expected: number) -> (),
toBeFalsy: () -> (),
toBeTruthy: () -> (),
}
type FunctionalCases = ExpectCases & {
toThrow: (expected: string?) -> (),
never: FunctionalCases,
}
expect(value: any): type BasicCases = {
toBe: (expected: any) -> (),
toBeDefined: () -> (),
toBeCloseTo: (expected: number, precision: number) -> (),
toBeGreaterThan: (expected: number) -> (),
toBeGreaterThanOrEqual: (expected: number) -> (),
toBeLessThan: (expected: number) -> (),
toBeLessThanOrEqual: (expected: number) -> (),
toBeNil: () -> (),
toBeNan: () -> (),
toHaveLength: (expected: number) -> (),
toBeFalsy: () -> (),
toBeTruthy: () -> (),
}
type ExpectCases = BasicCases & {
never: BasicCases,
}ExpectCasestype BasicCases = {
toBe: (expected: any) -> (),
toBeDefined: () -> (),
toBeCloseTo: (expected: number, precision: number) -> (),
toBeGreaterThan: (expected: number) -> (),
toBeGreaterThanOrEqual: (expected: number) -> (),
toBeLessThan: (expected: number) -> (),
toBeLessThanOrEqual: (expected: number) -> (),
toBeNil: () -> (),
toBeNan: () -> (),
toHaveLength: (expected: number) -> (),
toBeFalsy: () -> (),
toBeTruthy: () -> (),
}
type ExpectCases = BasicCases & {
never: BasicCases,
}Parameters
value: (...any) -> ...any | any- The value to expect.
expected
Expects a value to be true or non nil.
Similar to assert(value)
expected(value: any): ()Parameters
value: any- The value to expect.
Last updated on