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 |
Static Methods
static parseMarblesAsSubscriptions(marbles: string, runMode: boolean = false): SubscriptionLog
Parameters
| marbles | Type: |
| runMode | Optional. Default is Type: |
Returns
SubscriptionLog
static parseMarbles(marbles: string, values?: any, errorValue?: any, materializeInnerObservables: boolean = false, runMode: boolean = false): TestMessage[]
Parameters
| marbles | Type: |
| values | Optional. Default is Type: |
| errorValue | Optional. Default is Type: |
| materializeInnerObservables | Optional. Default is Type: |
| runMode | Optional. Default is Type: |
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: |
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 | Optional. Default is Values to use for the letters in |
| error | Optional. Default is The error to use for the |
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 | Optional. Default is Values to use for the letters in |
| error | Optional. Default is The error to use for the |
Returns
HotObservable<T>
expectObservable<T>(observable: Observable<T>, subscriptionMarbles: string = null)
Parameters
| observable | Type: |
| subscriptionMarbles | Optional. Default is Type: |
expectSubscriptions(actualSubscriptionLogs: SubscriptionLog[]): {
toBe: subscriptionLogsToBeFn;
}
Parameters
| actualSubscriptionLogs | Type: |
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: |
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