diff --git a/.changeset/six-elephants-rest.md b/.changeset/six-elephants-rest.md new file mode 100644 index 0000000000..f76fe08389 --- /dev/null +++ b/.changeset/six-elephants-rest.md @@ -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. diff --git a/plugins/scaffolder-node-test-utils/src/actions/mockActionContext.ts b/plugins/scaffolder-node-test-utils/src/actions/mockActionContext.ts index 1d45051753..076bb0ce22 100644 --- a/plugins/scaffolder-node-test-utils/src/actions/mockActionContext.ts +++ b/plugins/scaffolder-node-test-utils/src/actions/mockActionContext.ts @@ -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(opts: { + key: string; + fn: () => Promise | T; + }): Promise { + return opts.fn(); + }, getInitiatorCredentials: () => Promise.resolve(credentials), task: { id: 'mock-task-id',