From 3d6c89c36081630c0051842880a8749258469a1f Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 19 Aug 2025 10:09:27 +0200 Subject: [PATCH] docs/backend-system: remove usage of waitForTask in scheduler docs Signed-off-by: Patrik Oldsberg --- docs/backend-system/core-services/scheduler.md | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/docs/backend-system/core-services/scheduler.md b/docs/backend-system/core-services/scheduler.md index b8f8c6aac1..f61f77cc7e 100644 --- a/docs/backend-system/core-services/scheduler.md +++ b/docs/backend-system/core-services/scheduler.md @@ -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 }); ```