From f447bfc764407f912a0070c7462cae590ae9d03f Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Sun, 31 May 2026 13:27:17 +0200 Subject: [PATCH] test: fix mocks --- jest.config.js | 3 +++ src/__mocks__/actions-core.ts | 5 +++++ src/main.spec.ts | 4 +--- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 src/__mocks__/actions-core.ts diff --git a/jest.config.js b/jest.config.js index ee1db57..2e3d58c 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,6 +3,9 @@ module.exports = { testEnvironment: "node", roots: ["/src"], testMatch: ["**/*.spec.ts"], + moduleNameMapper: { + "^@actions/core$": "/src/__mocks__/actions-core.ts", + }, transform: { "^.+\\.ts$": "ts-jest", }, diff --git a/src/__mocks__/actions-core.ts b/src/__mocks__/actions-core.ts new file mode 100644 index 0000000..12631d0 --- /dev/null +++ b/src/__mocks__/actions-core.ts @@ -0,0 +1,5 @@ +export const getInput = jest.fn(() => ""); +export const info = jest.fn(); +export const warning = jest.fn(); +export const setOutput = jest.fn(); +export const setFailed = jest.fn(); diff --git a/src/main.spec.ts b/src/main.spec.ts index 1c7f1ee..7d768f3 100644 --- a/src/main.spec.ts +++ b/src/main.spec.ts @@ -439,9 +439,7 @@ describe("LocalCoreService", () => { localCoreService = new LocalCoreService(); }); - // Note: These tests would require mocking the @actions/core module - // In a real implementation, you might want to use jest.mock() to mock the entire module - // For now, we'll just test that the methods exist and can be called + // @actions/core is mocked via jest.config.js moduleNameMapper it("should have all required methods", () => { expect(typeof localCoreService.getInput).toBe("function");