sfcode
An Online Competing and Development Environment
|
Many of the core features of jasminewd are centered around automatically synchronizing your tests with the WebDriver control flow. However, jasminewd can synchronize with any scheduler as long as it implements the following interface:
Where execute
is the function used to put something on the scheduler. As long as your scheduler implements this interface, you can pass it into ‘require('jasminewd2’).init`.
Some schedulers need scheduled functions to use a specific implementation of the promise API. For instance, WebDriver has its ManagedPromise
implementation, which it needs in order to track tasks across then()
blocks. If your scheduler has its own promise implementation, you can implement the following interface:
If the promise
function is specified, jasminewd will use that function to generate all of its internal promises. If scheduler.promise
is not specified, jasminewd will try to use WebDriver's ManagedPromise
. If ManagedPromise
is not available (e.g. the control flow is disabled), jasminewd will default to using native promises.
If your scheduler requires a custom promise implementation, it is highly recommended that you implement the Idle API. This will help to mitigate issues with users who sometimes use other promise implementations (see https://github.com/angular/jasminewd/issues/68#issuecomment-262317167). To do this, implement the following interface:
Your scheduler must emit "idle"
when it becomes idle.
If you want your scheduler to be reset whenever a spec times out, implement the following interface:
jasminewd will automatically look for a reset
function and call it when specs time out. This is useful so that tasks from a timed out spec get cleared instead of continuing to tie up the scheduler and potentially getting executed during future specs.