From a15a3fbb1304fc1dd9a99548555b7a7276c3e9f2 Mon Sep 17 00:00:00 2001 From: Johan Brorson Date: Tue, 5 Apr 2022 16:51:17 +0200 Subject: [PATCH] fix: restore all mocks between tests Restore all mocks between tests in `buildJsonResults.test.js` to ensure that it works with Jest 24. --- __tests__/buildJsonResults.test.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/__tests__/buildJsonResults.test.js b/__tests__/buildJsonResults.test.js index 57990f5..2e19c17 100644 --- a/__tests__/buildJsonResults.test.js +++ b/__tests__/buildJsonResults.test.js @@ -9,7 +9,13 @@ let jsonResults; let ignoreJunitErrors = false; describe('buildJsonResults', () => { + beforeEach(() => { + jest.spyOn(fs, 'existsSync'); + }) + afterEach(() => { + jest.restoreAllMocks(); + if (ignoreJunitErrors !== true) { // Verify each tests JSON output results in a // compliant junit.xml file based on __tests__/lib/junit.xsd (jenkins xsd) @@ -410,7 +416,6 @@ describe('buildJsonResults', () => { { virtual: true }, ); - jest.spyOn(fs, 'existsSync'); fs.existsSync.mockReturnValue(true); const options = { @@ -439,5 +444,4 @@ describe('buildJsonResults', () => { ]), ); }); - });