Skip to content

Commit 204160d

Browse files
committed
test: improve fs mock implementation in readConfig tests
1 parent 93c10e8 commit 204160d

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

__tests__/readConfig.test.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import * as fs from 'fs';
22
import { readConfig, readJSONSync } from '../src/readConfig';
33

4-
jest.mock('fs', () => ({
5-
existsSync: jest.fn(),
6-
readFileSync: jest.fn(),
7-
promises: {
8-
access: jest.fn()
9-
}
10-
}));
4+
jest.mock('fs', () => {
5+
const actualFs = jest.requireActual('fs');
6+
return {
7+
...actualFs,
8+
existsSync: jest.fn(),
9+
readFileSync: jest.fn(),
10+
promises: {
11+
...actualFs.promises,
12+
access: jest.fn()
13+
}
14+
};
15+
});
16+
1117
jest.mock('@actions/core');
1218

1319
describe('readJSONSync', () => {

0 commit comments

Comments
 (0)