Package-level declarations

Types

Link copied to clipboard
sealed external interface AssertSnapshotOptions
Link copied to clipboard
typealias HookFn = (c: Any, done: (result: Any?) -> Unit) -> Any?

The hook function. The first argument is the context in which the hook is called. If the hook uses callbacks, the callback function is passed as the second argument.

Link copied to clipboard
sealed external interface HookOptions

Configuration options for hooks.

Link copied to clipboard
sealed external interface Mock<F : Function<*>>
Link copied to clipboard
sealed external interface MockFunctionCall<F : Function<*>, ReturnType, Args>
Link copied to clipboard
sealed external interface MockFunctionContext<F : Function<*>>

The MockFunctionContext class is used to inspect or manipulate the behavior of mocks created via the MockTracker APIs.

Link copied to clipboard
sealed external interface MockFunctionOptions
Link copied to clipboard
sealed external interface MockMethodOptions : MockFunctionOptions
Link copied to clipboard
sealed external interface MockModuleContext
Link copied to clipboard
sealed external interface MockModuleOptions
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
sealed external interface MockPropertyContextAccessesItemType
Link copied to clipboard
sealed external interface MockTimers

Mocking timers is a technique commonly used in software testing to simulate and control the behavior of timers, such as setInterval and setTimeout, without actually waiting for the specified time intervals.

Link copied to clipboard
sealed external interface MockTimersOptions
Link copied to clipboard
sealed external interface MockTimersOptionsApisItem
Link copied to clipboard
sealed external interface MockTracker

The MockTracker class is used to manage mocking functionality. The test runner module provides a top level mock export which is a MockTracker instance. Each test also provides its own MockTracker instance via the test context's mock property.

Link copied to clipboard
sealed external interface MockTrackerPropertyResult
Link copied to clipboard
sealed external interface RunOptions
Link copied to clipboard
sealed external interface RunOptionsIsolation
Link copied to clipboard
sealed external interface SuiteContext

An instance of SuiteContext is passed to each suite function in order to interact with the test runner. However, the SuiteContext constructor is not exposed as part of the API.

Link copied to clipboard
typealias SuiteFn = (s: SuiteContext) -> ERROR CLASS: Symbol not found for js.promise.PromiseResult<ERROR CLASS: Symbol not found for js.core.Void>

The type of a suite test function. The argument to this function is a {@link SuiteContext} object.

Link copied to clipboard
sealed external interface TestContext

An instance of TestContext is passed to each test function in order to interact with the test runner. However, the TestContext constructor is not exposed as part of the API.

Link copied to clipboard
sealed external interface TestContextAssert
Link copied to clipboard
typealias TestContextHookFn = (t: TestContext, done: (result: Any?) -> Unit) -> Any?

The hook function. The first argument is a TestContext object. If the hook uses callbacks, the callback function is passed as the second argument.

Link copied to clipboard
sealed external interface TestContextPlanOptions
Link copied to clipboard
sealed external interface TestContextWaitForOptions
Link copied to clipboard
typealias TestFn = (t: TestContext, done: (result: Any?) -> Unit) -> ERROR CLASS: Symbol not found for js.promise.PromiseResult<ERROR CLASS: Symbol not found for js.core.Void>

The type of a function passed to {@link test}. The first argument to this function is a {@link TestContext} object. If the test uses callbacks, the callback function is passed as the second argument.

Link copied to clipboard
sealed external interface TestOptions
Link copied to clipboard
sealed external interface TestShard
Link copied to clipboard
sealed external interface TestsStream : Readable

A successful call to run() will return a new TestsStream object, streaming a series of events representing the execution of the tests.

Properties

Link copied to clipboard
external val mock: MockTracker

Functions

Link copied to clipboard
external fun after(fn: HookFn = definedExternally, options: HookOptions = definedExternally)

This function creates a hook that runs after executing a suite.

Link copied to clipboard
external fun afterEach(fn: HookFn = definedExternally, options: HookOptions = definedExternally)

This function creates a hook that runs after each test in the current suite. The afterEach() hook is run even if the test fails.

Link copied to clipboard
external fun before(fn: HookFn = definedExternally, options: HookOptions = definedExternally)

This function creates a hook that runs before executing a suite.

Link copied to clipboard
external fun beforeEach(fn: HookFn = definedExternally, options: HookOptions = definedExternally)

This function creates a hook that runs before each test in the current suite.

Link copied to clipboard
suspend external fun only(): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun only(fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun only(name: String = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun only(options: TestOptions = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun only(name: String = definedExternally, options: TestOptions = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
Link copied to clipboard
external fun onlyAsync(): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun onlyAsync(fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun onlyAsync(name: String = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun onlyAsync(options: TestOptions = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>

external fun onlyAsync(name: String = definedExternally, options: TestOptions = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>

Shorthand for marking a test as only. This is the same as calling {@link test} with options.only set to true.

Link copied to clipboard
external fun run(options: RunOptions = definedExternally): TestsStream

Note: shard is used to horizontally parallelize test running across machines or processes, ideal for large-scale executions across varied environments. It's incompatible with watch mode, tailored for rapid code iteration by automatically rerunning tests on file changes.

Link copied to clipboard
suspend external fun skip(): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun skip(fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun skip(name: String = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun skip(options: TestOptions = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun skip(name: String = definedExternally, options: TestOptions = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
Link copied to clipboard
external fun skipAsync(): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun skipAsync(fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun skipAsync(name: String = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun skipAsync(options: TestOptions = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>

external fun skipAsync(name: String = definedExternally, options: TestOptions = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>

Shorthand for skipping a test. This is the same as calling {@link test} with options.skip set to true.

Link copied to clipboard
suspend external fun suite(fn: SuiteFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun suite(name: String = definedExternally, fn: SuiteFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun suite(options: TestOptions = definedExternally, fn: SuiteFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun suite(name: String = definedExternally, options: TestOptions = definedExternally, fn: SuiteFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
Link copied to clipboard
external fun suiteAsync(): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun suiteAsync(fn: SuiteFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun suiteAsync(name: String = definedExternally, fn: SuiteFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun suiteAsync(options: TestOptions = definedExternally, fn: SuiteFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>

external fun suiteAsync(name: String = definedExternally, options: TestOptions = definedExternally, fn: SuiteFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>

The suite() function is imported from the node:test module.

Link copied to clipboard
suspend external fun test(): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun test(fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun test(name: String = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun test(options: TestOptions = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun test(name: String = definedExternally, options: TestOptions = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
Link copied to clipboard
external fun testAsync(): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>

The node:test/reporters module exposes the builtin-reporters for node:test. To access it:

external fun testAsync(fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun testAsync(options: TestOptions = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun testAsync(name: String = definedExternally, options: TestOptions = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>

external fun testAsync(name: String = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>

The test() function is the value imported from the test module. Each invocation of this function results in reporting the test to the TestsStream.

Link copied to clipboard
suspend external fun todo(): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun todo(fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun todo(name: String = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun todo(options: TestOptions = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
suspend external fun todo(name: String = definedExternally, options: TestOptions = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for js.core.Void
Link copied to clipboard
external fun todoAsync(): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun todoAsync(fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun todoAsync(name: String = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>
external fun todoAsync(options: TestOptions = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>

external fun todoAsync(name: String = definedExternally, options: TestOptions = definedExternally, fn: TestFn = definedExternally): ERROR CLASS: Symbol not found for Promise<ERROR CLASS: Symbol not found for js.core.Void>

Shorthand for marking a test as TODO. This is the same as calling {@link test} with options.todo set to true.