Skip to content

Commit 6840e58

Browse files
committed
test: hoist ebs.test.js mocks to fix spurious core.error annotations
Signed-off-by: yuriyryabikov <22548029+kurok@users.noreply.github.com>
1 parent 136a1c3 commit 6840e58

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

tests/ebs.test.js

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
// Tests for buildEncryptedRootMapping. The function is a pure transform
22
// of a DescribeImages response — no AWS/GitHub stubbing required.
33
//
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+
}));
1916

2017
const { buildEncryptedRootMapping } = require('../src/aws');
2118

0 commit comments

Comments
 (0)