untilTaskRunDone
The untilTaskRunDone
method returns a Promise that resolves when a task run has finished running, regardless of whether it was successful or not.
untilTaskRunDone(taskRunId: string): Promise<void>
Type | Description | |
---|---|---|
taskRunId | string | The |
returns | Promise<void> | A promise that will resolve when the task run finishes. |
This is useful if you want to have a parent task that will keep running until its child tasks have concluded.
In this context, 'done' means that the test run succeeded, deleted or failed (and, if relevant, all retries have been attempted). If a task is configured to 'repeat', future iterations are not included and the promise will resolve after the first is done.
Example
This example demonstrates using untilTaskRunDone to wait for a task to complete before continuing execution.
import {createManager} from 'tinytick';
const manager = createManager().start();
manager.setTask('ping', async () => await fetch('https://example.org'));
const taskRunId = manager.scheduleTaskRun('ping');
await manager.untilTaskRunDone(taskRunId);
// Continue execution
Since
v1.2.4