rxjs / latest / api / testing / testscheduler.html

TestScheduler

class stable

class TestScheduler extends VirtualTimeScheduler {
  static frameTimeFactor: 10
  static parseMarblesAsSubscriptions(marbles: string, runMode: boolean = false): SubscriptionLog
  static parseMarbles(marbles: string, values?: any, errorValue?: any, materializeInnerObservables: boolean = false, runMode: boolean = false): TestMessage[]
  constructor(assertDeepEqual: (actual: any, expected: any) => boolean | void)
  get hotObservables: HotObservable<any>[]
  get coldObservables: ColdObservable<any>[]
  assertDeepEqual: (actual: any, expected: any) => boolean | void
  createTime(marbles: string): number
  createColdObservable<T = string>(marbles: string, values?: { [marble: string]: T; }, error?: any): ColdObservable<T>
  createHotObservable<T = string>(marbles: string, values?: { [marble: string]: T; }, error?: any): HotObservable<T>
  expectObservable<T>(observable: Observable<T>, subscriptionMarbles: string = null)
  expectSubscriptions(actualSubscriptionLogs: SubscriptionLog[]): {...}
  flush()
  run<T>(callback: (helpers: RunHelpers) => T): T

  // inherited from index/VirtualTimeScheduler
  static frameTimeFactor: 10
  constructor(schedulerActionCtor: typeof AsyncAction = VirtualAction as any, maxFrames: number = Infinity)
  frame: number
  index: number
  maxFrames: number
  flush(): void
}

Static Properties

Property Type Description
frameTimeFactor 10

The number of virtual time units each character in a marble diagram represents. If the test scheduler is being used in "run mode", via the run method, this is temporarly set to 1 for the duration of the run block, then set back to whatever value it was.

Static Methods

static parseMarblesAsSubscriptions(marbles: string, runMode: boolean = false): SubscriptionLog

Parameters

marbles string
runMode boolean

Optional. Default is false.

Returns

SubscriptionLog

static parseMarbles(marbles: string, values?: any, errorValue?: any, materializeInnerObservables: boolean = false, runMode: boolean = false): TestMessage[]

Parameters

marbles string
values any

Optional. Default is undefined.

errorValue any

Optional. Default is undefined.

materializeInnerObservables boolean

Optional. Default is false.

runMode boolean

Optional. Default is false.

Returns

TestMessage[]

Constructor

constructor(assertDeepEqual: (actual: any, expected: any) => boolean | void)

Parameters

assertDeepEqual (actual: any, expected: any) => boolean | void

A function to set up your assertion for your test harness

Properties

Property Type Description
hotObservables HotObservable<any>[] Read-only.
coldObservables ColdObservable<any>[] Read-only.
assertDeepEqual (actual: any, expected: any) => boolean | void

A function to set up your assertion for your test harness

Declared in constructor.

Methods

createTime(marbles: string): number

Parameters

marbles string

Returns

number

createColdObservable<T = string>(marbles: string, values?: { [marble: string]: T; }, error?: any): ColdObservable<T>

Parameters

marbles string

A diagram in the marble DSL. Letters map to keys in values if provided.

values { [marble: string]: T; }

Optional. Default is undefined.

Values to use for the letters in marbles. If ommitted, the letters themselves are used.

error any

Optional. Default is undefined.

The error to use for the # marble (if present).

Returns

ColdObservable<T>

createHotObservable<T = string>(marbles: string, values?: { [marble: string]: T; }, error?: any): HotObservable<T>

Parameters

marbles string

A diagram in the marble DSL. Letters map to keys in values if provided.

values { [marble: string]: T; }

Optional. Default is undefined.

Values to use for the letters in marbles. If ommitted, the letters themselves are used.

error any

Optional. Default is undefined.

The error to use for the # marble (if present).

Returns

HotObservable<T>

expectObservable<T>(observable: Observable<T>, subscriptionMarbles: string = null)

Parameters

observable Observable<T>
subscriptionMarbles string

Optional. Default is null.

expectSubscriptions(actualSubscriptionLogs: SubscriptionLog[]): { toBe: subscriptionLogsToBeFn; }

Parameters

actualSubscriptionLogs SubscriptionLog[]

Returns

{ toBe: subscriptionLogsToBeFn; }

flush()

Parameters

There are no parameters.

run<T>(callback: (helpers: RunHelpers) => T): T

The run method performs the test in 'run mode' - in which schedulers used within the test automatically delegate to the TestScheduler. That is, in 'run mode' there is no need to explicitly pass a TestScheduler instance to observable creators or operators.

Parameters

callback (helpers: RunHelpers) => T

Returns

T

© 2015–2022 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors.
Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0.
https://rxjs.dev/api/testing/TestScheduler