Skip to content

Commit

Permalink
Try to restore all mocks between tests
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew W. Harn <[email protected]>
  • Loading branch information
awharn committed Nov 7, 2023
1 parent 882badd commit c36511c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions __tests__/beforeTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ beforeAll(() => {
// If the worker runs out of memory, this needs to be reset
require('events').EventEmitter.defaultMaxListeners = Infinity;
});

afterAll(() => {
jest.restoreAllMocks();
})
2 changes: 1 addition & 1 deletion packages/imperative/__tests__/src/TestUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,6 @@ export async function setupConfigToLoad(properties?: IConfig, opts: IConfigOpts
}

const fakeConfig = await Config.load("fakeapp", opts);
tempMocks.push(jest.spyOn(ImperativeConfig.instance, "config", "get").mockReturnValue(fakeConfig));
jest.spyOn(ImperativeConfig.instance, "config", "get").mockReturnValue(fakeConfig);
tempMocks.forEach(mock => mock.mockRestore()); // Reset all mocks
}

0 comments on commit c36511c

Please sign in to comment.