diff --git a/config/jest.config.js b/config/jest.config.js index 30b3aba..18a55f6 100644 --- a/config/jest.config.js +++ b/config/jest.config.js @@ -11,8 +11,9 @@ const jestConfig = { testEnvironment: "node", testRegex: "(/__tests__/.*|(\\.|/)test)\\.ts", moduleNameMapper: { - "^@actions/core$": "/__mocks__/actions-core.js", - "^@actions/tool-cache$": "/__mocks__/actions-tool-cache.js", + "^@actions/core$": "/__mocks__/actions-core.ts", + "^@actions/tool-cache$": "/__mocks__/actions-tool-cache.ts", + "^@actions/exec$": "/__mocks__/actions-exec.ts", }, transform: { ".ts": [ diff --git a/package-lock.json b/package-lock.json index 8a643b2..b96d951 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@1password/op-js": "^0.1.11", "@actions/core": "^3.0.0", - "@actions/exec": "^1.1.1", + "@actions/exec": "^3.0.0", "@actions/tool-cache": "^4.0.0", "dotenv": "^17.2.2" }, @@ -82,30 +82,14 @@ "@actions/http-client": "^4.0.0" } }, - "node_modules/@actions/core/node_modules/@actions/exec": { + "node_modules/@actions/exec": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-3.0.0.tgz", "integrity": "sha512-6xH/puSoNBXb72VPlZVm7vQ+svQpFyA96qdDBvhB8eNZOE8LtPf9L4oAsfzK/crCL8YZ+19fKYVnM63Sl+Xzlw==", - "license": "MIT", "dependencies": { "@actions/io": "^3.0.2" } }, - "node_modules/@actions/core/node_modules/@actions/io": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@actions/io/-/io-3.0.2.tgz", - "integrity": "sha512-nRBchcMM+QK1pdjO7/idu86rbJI5YHUKCvKs0KxnSYbVe3F51UfGxuZX4Qy/fWlp6l7gWFwIkrOzN+oUK03kfw==", - "license": "MIT" - }, - "node_modules/@actions/exec": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-1.1.1.tgz", - "integrity": "sha512-+sCcHHbVdk93a0XT19ECtO/gIXoxvdsgQLzb2fE2/5sIZmWQuluYyjPQtrtTHdU1YzTZ7bAPN4sITq2xi1679w==", - "license": "MIT", - "dependencies": { - "@actions/io": "^1.0.1" - } - }, "node_modules/@actions/http-client": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-4.0.0.tgz", @@ -117,10 +101,9 @@ } }, "node_modules/@actions/io": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/@actions/io/-/io-1.1.3.tgz", - "integrity": "sha512-wi9JjgKLYS7U/z8PPbco+PvTb/nRWjeoFlJ1Qer83k/3C5PHQi28hiVdeE2kHXmIL99mQFawx8qt/JPjZilJ8Q==", - "license": "MIT" + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/@actions/io/-/io-3.0.2.tgz", + "integrity": "sha512-nRBchcMM+QK1pdjO7/idu86rbJI5YHUKCvKs0KxnSYbVe3F51UfGxuZX4Qy/fWlp6l7gWFwIkrOzN+oUK03kfw==" }, "node_modules/@actions/tool-cache": { "version": "4.0.0", @@ -135,21 +118,6 @@ "semver": "^7.7.3" } }, - "node_modules/@actions/tool-cache/node_modules/@actions/exec": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/@actions/exec/-/exec-3.0.0.tgz", - "integrity": "sha512-6xH/puSoNBXb72VPlZVm7vQ+svQpFyA96qdDBvhB8eNZOE8LtPf9L4oAsfzK/crCL8YZ+19fKYVnM63Sl+Xzlw==", - "license": "MIT", - "dependencies": { - "@actions/io": "^3.0.2" - } - }, - "node_modules/@actions/tool-cache/node_modules/@actions/io": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/@actions/io/-/io-3.0.2.tgz", - "integrity": "sha512-nRBchcMM+QK1pdjO7/idu86rbJI5YHUKCvKs0KxnSYbVe3F51UfGxuZX4Qy/fWlp6l7gWFwIkrOzN+oUK03kfw==", - "license": "MIT" - }, "node_modules/@ampproject/remapping": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", diff --git a/package.json b/package.json index ff3edae..02013ed 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ "dependencies": { "@1password/op-js": "^0.1.11", "@actions/core": "^3.0.0", - "@actions/exec": "^1.1.1", + "@actions/exec": "^3.0.0", "@actions/tool-cache": "^4.0.0", "dotenv": "^17.2.2" }, diff --git a/src/__mocks__/actions-core.js b/src/__mocks__/actions-core.ts similarity index 100% rename from src/__mocks__/actions-core.js rename to src/__mocks__/actions-core.ts diff --git a/src/__mocks__/actions-exec.ts b/src/__mocks__/actions-exec.ts new file mode 100644 index 0000000..517e543 --- /dev/null +++ b/src/__mocks__/actions-exec.ts @@ -0,0 +1,5 @@ +module.exports = { + getExecOutput: jest.fn(() => ({ + stdout: "MOCK_SECRET", + })), +}; diff --git a/src/__mocks__/actions-tool-cache.js b/src/__mocks__/actions-tool-cache.js deleted file mode 100644 index 12925b7..0000000 --- a/src/__mocks__/actions-tool-cache.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - downloadTool: jest.fn(), - extractTar: jest.fn(), - extractZip: jest.fn(), - cacheDir: jest.fn((dir) => Promise.resolve(dir)), - find: jest.fn(() => ""), -}; diff --git a/src/__mocks__/actions-tool-cache.ts b/src/__mocks__/actions-tool-cache.ts new file mode 100644 index 0000000..2a35714 --- /dev/null +++ b/src/__mocks__/actions-tool-cache.ts @@ -0,0 +1,10 @@ +module.exports = { + downloadTool: jest.fn(), + extractTar: jest.fn(), + extractZip: jest.fn(), + cacheDir: jest.fn, [string]>(async (dir) => { + await Promise.resolve(); + return dir; + }), + find: jest.fn(() => ""), +}; diff --git a/src/utils.test.ts b/src/utils.test.ts index 0dd0ffe..f66a31f 100644 --- a/src/utils.test.ts +++ b/src/utils.test.ts @@ -15,12 +15,6 @@ import { envServiceAccountToken, } from "./constants"; -jest.mock("@actions/core"); -jest.mock("@actions/exec", () => ({ - getExecOutput: jest.fn(() => ({ - stdout: "MOCK_SECRET", - })), -})); jest.mock("@1password/op-js"); beforeEach(() => {