From e5d7353d74311846d226de04c5d5b70c70e4fec5 Mon Sep 17 00:00:00 2001 From: Jill Regan Date: Tue, 24 Feb 2026 09:40:54 -0500 Subject: [PATCH] use module exports --- config/jest.config.js | 6 +++++- src/__mocks__/actions-core.js | 14 ++++++++++++++ src/__mocks__/actions-tool-cache.js | 7 +++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/__mocks__/actions-core.js create mode 100644 src/__mocks__/actions-tool-cache.js diff --git a/config/jest.config.js b/config/jest.config.js index 5b00a18..30b3aba 100644 --- a/config/jest.config.js +++ b/config/jest.config.js @@ -10,6 +10,10 @@ const jestConfig = { rootDir: "../src/", testEnvironment: "node", testRegex: "(/__tests__/.*|(\\.|/)test)\\.ts", + moduleNameMapper: { + "^@actions/core$": "/__mocks__/actions-core.js", + "^@actions/tool-cache$": "/__mocks__/actions-tool-cache.js", + }, transform: { ".ts": [ "ts-jest", @@ -25,4 +29,4 @@ const jestConfig = { verbose: true, }; -export default jestConfig; +module.exports = jestConfig; diff --git a/src/__mocks__/actions-core.js b/src/__mocks__/actions-core.js new file mode 100644 index 0000000..3e41919 --- /dev/null +++ b/src/__mocks__/actions-core.js @@ -0,0 +1,14 @@ +module.exports = { + getInput: jest.fn(() => ""), + getBooleanInput: jest.fn(() => false), + setOutput: jest.fn(), + setSecret: jest.fn(), + exportVariable: jest.fn(), + setFailed: jest.fn(), + info: jest.fn(), + warning: jest.fn(), + error: jest.fn(), + debug: jest.fn(), + addPath: jest.fn(), + isDebug: jest.fn(() => false), +}; diff --git a/src/__mocks__/actions-tool-cache.js b/src/__mocks__/actions-tool-cache.js new file mode 100644 index 0000000..12925b7 --- /dev/null +++ b/src/__mocks__/actions-tool-cache.js @@ -0,0 +1,7 @@ +module.exports = { + downloadTool: jest.fn(), + extractTar: jest.fn(), + extractZip: jest.fn(), + cacheDir: jest.fn((dir) => Promise.resolve(dir)), + find: jest.fn(() => ""), +};