|
1 | 1 | // Tests for buildEncryptedRootMapping. The function is a pure transform |
2 | 2 | // of a DescribeImages response — no AWS/GitHub stubbing required. |
3 | 3 | // |
4 | | -// aws.js requires ./config at module load; mock it so the require chain |
5 | | -// resolves without a valid Config singleton (tests don't touch config- |
6 | | -// dependent code paths in this file). |
7 | | - |
8 | | -beforeAll(() => { |
9 | | - jest.doMock('../src/config', () => ({ |
10 | | - input: { mode: 'start', debug: 'false' }, |
11 | | - githubContext: { owner: 'o', repo: 'r' }, |
12 | | - tagSpecifications: null, |
13 | | - })); |
14 | | - jest.doMock('@actions/core', () => ({ |
15 | | - info: jest.fn(), warning: jest.fn(), error: jest.fn(), setFailed: jest.fn(), getInput: jest.fn(), |
16 | | - startGroup: jest.fn(), endGroup: jest.fn(), |
17 | | - })); |
18 | | -}); |
| 4 | +// aws.js and config.js are required at module load time, so mocks must be |
| 5 | +// in place before any require() runs. jest.mock() is hoisted by Jest's |
| 6 | +// transform and executes before module-level require() calls. |
| 7 | +jest.mock('../src/config', () => ({ |
| 8 | + input: { mode: 'start', debug: 'false' }, |
| 9 | + githubContext: { owner: 'o', repo: 'r' }, |
| 10 | + tagSpecifications: null, |
| 11 | +})); |
| 12 | +jest.mock('@actions/core', () => ({ |
| 13 | + info: jest.fn(), warning: jest.fn(), error: jest.fn(), setFailed: jest.fn(), getInput: jest.fn(), |
| 14 | + startGroup: jest.fn(), endGroup: jest.fn(), |
| 15 | +})); |
19 | 16 |
|
20 | 17 | const { buildEncryptedRootMapping } = require('../src/aws'); |
21 | 18 |
|
|
0 commit comments