Package-level declarations

Types

Link copied to clipboard

Control the virtual clock time of a CoroutineDispatcher.

Link copied to clipboard

CoroutineDispatcher that performs both immediate and lazy execution of coroutines in tests and uses a TestCoroutineScheduler to control its virtual clock.

Link copied to clipboard

An exception handler that captures uncaught exceptions in tests.

Link copied to clipboard

This is a scheduler for coroutines used in tests, providing the delay-skipping behavior.

Link copied to clipboard

A scope which provides detailed control over the execution of coroutines for tests.

Link copied to clipboard

A test dispatcher that can interface with a TestCoroutineScheduler.

Link copied to clipboard
expect class TestResult

A test result.

actual typealias TestResult = Promise<Unit>
actual typealias TestResult = Unit
actual typealias TestResult = Unit
actual typealias TestResult = Promise<JsAny?>
Link copied to clipboard

A coroutine scope that for launching test coroutines.

Link copied to clipboard

Access uncaught coroutine exceptions captured during test execution.

Properties

Link copied to clipboard
Link copied to clipboard

List of uncaught coroutine exceptions, for backward compatibility.

Functions

Link copied to clipboard

Moves the virtual clock of this dispatcher forward by the specified amount, running the scheduled tasks in the meantime.

Advances the testScheduler by delayTimeMillis and runs the tasks up to that moment (inclusive).

Link copied to clipboard

Advances the testScheduler to the point where there are no tasks remaining.

Advances the testScheduler to the point where there are no tasks remaining.

Link copied to clipboard

A coroutine scope for launching test coroutines.

Link copied to clipboard

Resets state of the Dispatchers.Main to the original main dispatcher.

Link copied to clipboard
fun runBlockingTest(context: CoroutineContext = EmptyCoroutineContext, testBody: suspend TestCoroutineScope.() -> Unit)

Executes a testBody inside an immediate execution dispatcher.

Link copied to clipboard

Convenience method for calling runBlockingTest on an existing TestCoroutineDispatcher.

Convenience method for calling runBlockingTest on an existing TestCoroutineScope.

fun TestScope.runBlockingTest(block: suspend TestScope.() -> Unit)

Convenience method for calling runBlockingTestOnTestScope on an existing TestScope.

Link copied to clipboard
fun runBlockingTestOnTestScope(context: CoroutineContext = EmptyCoroutineContext, testBody: suspend TestScope.() -> Unit)

A version of runBlockingTest that works with TestScope.

Link copied to clipboard

Run any tasks that are pending at the current virtual time, according to the testScheduler.

Run any tasks that are pending at the current virtual time, according to the testScheduler.

Link copied to clipboard
fun runTest(context: CoroutineContext = EmptyCoroutineContext, dispatchTimeoutMs: Long, testBody: suspend TestScope.() -> Unit): TestResult
fun runTest(context: CoroutineContext = EmptyCoroutineContext, timeout: Duration = DEFAULT_TIMEOUT.getOrThrow(), testBody: suspend TestScope.() -> Unit): TestResult

Executes testBody as a test in a new coroutine, returning TestResult.

Link copied to clipboard
fun TestScope.runTest(dispatchTimeoutMs: Long, testBody: suspend TestScope.() -> Unit): TestResult

Performs runTest on an existing TestScope.

fun TestScope.runTest(timeout: Duration = DEFAULT_TIMEOUT.getOrThrow(), testBody: suspend TestScope.() -> Unit): TestResult

Performs runTest on an existing TestScope. See the documentation for runTest for details.

fun TestCoroutineScope.runTest(dispatchTimeoutMs: Long = DEFAULT_DISPATCH_TIMEOUT_MS, block: suspend TestCoroutineScope.() -> Unit): TestResult

Runs a test in a TestCoroutineScope based on this one.

Link copied to clipboard
fun runTestWithLegacyScope(context: CoroutineContext = EmptyCoroutineContext, dispatchTimeoutMs: Long = DEFAULT_DISPATCH_TIMEOUT_MS, testBody: suspend TestCoroutineScope.() -> Unit)

This is an overload of runTest that works with TestCoroutineScope.

Link copied to clipboard

Sets the given dispatcher as an underlying dispatcher of Dispatchers.Main. All subsequent usages of Dispatchers.Main will use the given dispatcher under the hood.

Link copied to clipboard
fun StandardTestDispatcher(scheduler: TestCoroutineScheduler? = null, name: String? = null): TestDispatcher

Creates an instance of a TestDispatcher whose tasks are run inside calls to the scheduler.

Link copied to clipboard
fun TestCoroutineScope(context: CoroutineContext = EmptyCoroutineContext): TestCoroutineScope

A coroutine scope for launching test coroutines using TestCoroutineDispatcher.

Link copied to clipboard
fun TestScope(context: CoroutineContext = EmptyCoroutineContext): TestScope

Creates a TestScope.

Link copied to clipboard

Creates an instance of an unconfined TestDispatcher.