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

Type: string.

runMode

Optional. Default is false.

Type: boolean.

Returns

SubscriptionLog

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

Parameters

marbles

Type: string.

values

Optional. Default is undefined.

Type: any.

errorValue

Optional. Default is undefined.

Type: any.

materializeInnerObservables

Optional. Default is false.

Type: boolean.

runMode

Optional. Default is false.

Type: boolean.

Returns

TestMessage[]

Constructor

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

Parameters

assertDeepEqual

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

Type: string.

Returns

number

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

Parameters

marbles

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

values

Optional. Default is undefined.

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

error

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

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

values

Optional. Default is undefined.

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

error

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

Type: Observable.

subscriptionMarbles

Optional. Default is null.

Type: string.

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

Parameters

actualSubscriptionLogs

Type: 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

Type: (helpers: RunHelpers) => T.

Returns

T

© 2015–2021 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