Changing the default behaviour of the checkpoint in createMockActionContext. It will reduce the code boilerplate in the tests where checkpoint is used.

Signed-off-by: Bogdan Nechyporenko <bnechyporenko@bol.com>
This commit is contained in:
Bogdan Nechyporenko
2025-02-13 21:50:54 +01:00
parent b21d3034d0
commit 7ec0a5ae39
2 changed files with 12 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-node-test-utils': patch
---
Changing the default behaviour of the checkpoint in createMockActionContext. It will reduce the code boilerplate in the tests where checkpoint is used.
@@ -21,7 +21,7 @@ import {
mockCredentials,
mockServices,
} from '@backstage/backend-test-utils';
import { JsonObject } from '@backstage/types';
import { JsonObject, JsonValue } from '@backstage/types';
import { ActionContext } from '@backstage/plugin-scaffolder-node';
/**
@@ -43,7 +43,12 @@ export const createMockActionContext = <
output: jest.fn(),
createTemporaryDirectory: jest.fn(),
input: {} as TActionInput,
checkpoint: jest.fn(),
async checkpoint<T extends JsonValue | void>(opts: {
key: string;
fn: () => Promise<T> | T;
}): Promise<T> {
return opts.fn();
},
getInitiatorCredentials: () => Promise.resolve(credentials),
task: {
id: 'mock-task-id',