Skip to content

Commit

Permalink
Mock fs.existsSync in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobwgillespie committed Jul 14, 2021
1 parent 0453e51 commit e93556c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions __tests__/cache-save.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as core from '@actions/core';
import * as cache from '@actions/cache';
import * as glob from '@actions/glob';
import fs from 'fs';
import path from 'path';

import * as utils from '../src/cache-utils';
Expand Down Expand Up @@ -28,6 +29,7 @@ describe('run', () => {
let saveCacheSpy: jest.SpyInstance;
let getCommandOutputSpy: jest.SpyInstance;
let hashFilesSpy: jest.SpyInstance;
let existsSpy: jest.SpyInstance;

beforeEach(() => {
getInputSpy = jest.spyOn(core, 'getInput');
Expand Down Expand Up @@ -63,6 +65,9 @@ describe('run', () => {
}
});

existsSpy = jest.spyOn(fs, 'existsSync');
existsSpy.mockImplementation(() => true);

// utils
getCommandOutputSpy = jest.spyOn(utils, 'getCommandOutput');
});
Expand Down

0 comments on commit e93556c

Please sign in to comment.