Skip to content

Commit e93556c

Browse files
Mock fs.existsSync in tests
1 parent 0453e51 commit e93556c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

__tests__/cache-save.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as core from '@actions/core';
22
import * as cache from '@actions/cache';
33
import * as glob from '@actions/glob';
4+
import fs from 'fs';
45
import path from 'path';
56

67
import * as utils from '../src/cache-utils';
@@ -28,6 +29,7 @@ describe('run', () => {
2829
let saveCacheSpy: jest.SpyInstance;
2930
let getCommandOutputSpy: jest.SpyInstance;
3031
let hashFilesSpy: jest.SpyInstance;
32+
let existsSpy: jest.SpyInstance;
3133

3234
beforeEach(() => {
3335
getInputSpy = jest.spyOn(core, 'getInput');
@@ -63,6 +65,9 @@ describe('run', () => {
6365
}
6466
});
6567

68+
existsSpy = jest.spyOn(fs, 'existsSync');
69+
existsSpy.mockImplementation(() => true);
70+
6671
// utils
6772
getCommandOutputSpy = jest.spyOn(utils, 'getCommandOutput');
6873
});

0 commit comments

Comments
 (0)