docs/backend-system: remove usage of waitForTask in scheduler docs

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2025-08-19 10:09:27 +02:00
parent e545c21ef6
commit 3d6c89c360
+4 -11
View File
@@ -134,7 +134,7 @@ Responds with
The `@backstage/backend-test-utils` package provides `mockServices.scheduler`, which provides a mocked implementation of the scheduler service that can be used in tests. This mocked implementation is used by default in `startTestBackend`, and it will immediately run any registered tasks on startup as long as they're not configured to run manually or with an initial delay.
A dedicated instance can be used for more control during testing, with the mock implementation providing additional utilities to trigger and wait for tasks to complete:
A dedicated instance can be used for more control during testing:
```ts
it('should trigger a task', async () => {
@@ -144,16 +144,9 @@ it('should trigger a task', async () => {
features: [scheduler.factory()],
});
// Start waiting for some task to complete
const waitForTask = scheduler.waitForTask('some-task-id');
await scheduler.triggerTask('some-task-id');
// Call an endpoit that triggers a task
const res = await request(server).post(
'/api/my-plugin/route-that-triggers-a-task',
);
expect(res.status).toBe(200);
// Wait for the task to complete
await waitForTask;
// Next verify that the plugin state is updated accordingly
// e.g. by calling the API or verifying database state
});
```