Package-level declarations

Types

Link copied to clipboard

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

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 = JsPromiseInterfaceForTesting
typealias TestResult = JsPromiseInterfaceForTesting

A test result.

actual typealias TestResult = Unit
typealias TestResult = Unit

A test result.

actual typealias TestResult = Unit
typealias TestResult = Unit

A test result.

actual typealias TestResult = JsPromiseInterfaceForTesting
typealias TestResult = JsPromiseInterfaceForTesting

A test result.

actual typealias TestResult = Unit
typealias TestResult = Unit

A test result.

Link copied to clipboard
sealed interface TestScope : CoroutineScope

A coroutine scope that for launching test coroutines.

Functions

Link copied to clipboard

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

Link copied to clipboard

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

Link copied to clipboard

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

Link copied to clipboard

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.

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 TestScope(context: CoroutineContext = EmptyCoroutineContext): TestScope

Creates a TestScope.

Link copied to clipboard

Creates an instance of an unconfined TestDispatcher.