|
1 | | -import os from 'node:os'; |
2 | | - |
3 | | -import * as core from '@actions/core'; |
4 | | -import * as exec from '@actions/exec'; |
5 | | -import * as tc from '@actions/tool-cache'; |
6 | | - |
7 | | -import { run } from '.'; |
8 | | - |
9 | | -jest.mock('@actions/core'); |
10 | | -jest.mock('@actions/exec'); |
11 | | -jest.mock('@actions/tool-cache'); |
12 | | -jest.mock('node:os'); |
13 | | - |
14 | | -const mockedCore = jest.mocked(core); |
15 | | -const mockedExec = jest.mocked(exec); |
16 | | -const mockedTc = jest.mocked(tc); |
17 | | -const mockedOs = jest.mocked(os); |
| 1 | +import type { arch, platform } from 'node:os'; |
| 2 | + |
| 3 | +import type { addPath, getInput, setFailed } from '@actions/core'; |
| 4 | +import type { exec } from '@actions/exec'; |
| 5 | +import type { |
| 6 | + cacheFile, |
| 7 | + downloadTool, |
| 8 | + extractTar, |
| 9 | + extractZip, |
| 10 | + find, |
| 11 | +} from '@actions/tool-cache'; |
| 12 | +import { jest } from '@jest/globals'; |
| 13 | + |
| 14 | +const mockedCore: { |
| 15 | + getInput: jest.MockedFunction<typeof getInput>; |
| 16 | + addPath: jest.MockedFunction<typeof addPath>; |
| 17 | + setFailed: jest.MockedFunction<typeof setFailed>; |
| 18 | +} = { |
| 19 | + getInput: jest.fn(), |
| 20 | + addPath: jest.fn(), |
| 21 | + setFailed: jest.fn(), |
| 22 | +}; |
| 23 | + |
| 24 | +const mockedExec: { |
| 25 | + exec: jest.MockedFunction<typeof exec>; |
| 26 | +} = { |
| 27 | + exec: jest.fn(), |
| 28 | +}; |
| 29 | + |
| 30 | +const mockedTc: { |
| 31 | + downloadTool: jest.MockedFunction<typeof downloadTool>; |
| 32 | + extractTar: jest.MockedFunction<typeof extractTar>; |
| 33 | + extractZip: jest.MockedFunction<typeof extractZip>; |
| 34 | + cacheFile: jest.MockedFunction<typeof cacheFile>; |
| 35 | + find: jest.MockedFunction<typeof find>; |
| 36 | +} = { |
| 37 | + downloadTool: jest.fn(), |
| 38 | + extractTar: jest.fn(), |
| 39 | + extractZip: jest.fn(), |
| 40 | + cacheFile: jest.fn(), |
| 41 | + find: jest.fn(), |
| 42 | +}; |
| 43 | + |
| 44 | +const mockedOs: { |
| 45 | + platform: jest.MockedFunction<typeof platform>; |
| 46 | + arch: jest.MockedFunction<typeof arch>; |
| 47 | +} = { |
| 48 | + platform: jest.fn(), |
| 49 | + arch: jest.fn(), |
| 50 | +}; |
| 51 | + |
| 52 | +jest.unstable_mockModule('@actions/core', () => mockedCore); |
| 53 | +jest.unstable_mockModule('@actions/exec', () => mockedExec); |
| 54 | +jest.unstable_mockModule('@actions/tool-cache', () => mockedTc); |
| 55 | +jest.unstable_mockModule('node:os', () => mockedOs); |
| 56 | + |
| 57 | +const { run } = await import('./index.js'); |
18 | 58 |
|
19 | 59 | beforeEach(() => { |
20 | 60 | jest.resetAllMocks(); |
|
0 commit comments