From 5fc57c997436d4148699572ee57fc6764704ce05 Mon Sep 17 00:00:00 2001 From: Natalie Carey Date: Thu, 17 Aug 2023 16:17:15 +0100 Subject: [PATCH 1/2] Checking before deleting as it sometimes fails when testing. --- lib/sync-changes.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/sync-changes.js b/lib/sync-changes.js index 75484df843..c01401fe02 100644 --- a/lib/sync-changes.js +++ b/lib/sync-changes.js @@ -23,7 +23,9 @@ function flagError (error) { } function unflagError () { - fs.unlinkSync(errorsFile) + if (fs.existsSync(errorsFile)) { + fs.unlinkSync(errorsFile) + } } function pageLoaded () { From 2c2943dd1a316430fabd66b47a27f2a1288aaf90 Mon Sep 17 00:00:00 2001 From: Ben Surgison Date: Wed, 23 Aug 2023 17:59:40 +0100 Subject: [PATCH 2/2] Fix test --- lib/sync-changes.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sync-changes.test.js b/lib/sync-changes.test.js index a3f4cb8c94..3974f55901 100644 --- a/lib/sync-changes.test.js +++ b/lib/sync-changes.test.js @@ -58,7 +58,7 @@ describe('sync-changes', () => { syncChanges.pageLoaded() - expect(fs.existsSync).toHaveBeenCalledTimes(3) + expect(fs.existsSync).toHaveBeenCalledTimes(4) expect(fs.existsSync).toHaveBeenCalledWith(errorsFile) expect(fs.unlinkSync).toHaveBeenCalledTimes(1)