From e93556ca6645851a427f77742aeb1b22a95b4700 Mon Sep 17 00:00:00 2001 From: Jacob Gillespie Date: Wed, 14 Jul 2021 20:11:07 +0100 Subject: [PATCH] Mock fs.existsSync in tests --- __tests__/cache-save.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/__tests__/cache-save.test.ts b/__tests__/cache-save.test.ts index 4e678945..90c29ab2 100644 --- a/__tests__/cache-save.test.ts +++ b/__tests__/cache-save.test.ts @@ -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'; @@ -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'); @@ -63,6 +65,9 @@ describe('run', () => { } }); + existsSpy = jest.spyOn(fs, 'existsSync'); + existsSpy.mockImplementation(() => true); + // utils getCommandOutputSpy = jest.spyOn(utils, 'getCommandOutput'); });