Skip to content

Commit 22f4ad1

Browse files
committed
Restore all sinon stubs after each test
1 parent b0fb2d6 commit 22f4ad1

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/annotator/test/sidebar-test.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,6 @@ describe('Sidebar', () => {
3030
let fakeSendErrorsTo;
3131
let fakeEmitter;
3232

33-
beforeAll(() => {
34-
// Make `requestAnimationFrame` invoke its callback synchronously. rAF is
35-
// used to debounce some internal actions.
36-
sinon.stub(window, 'requestAnimationFrame').yields();
37-
});
38-
39-
afterAll(() => {
40-
window.requestAnimationFrame.restore();
41-
});
42-
4333
// Helpers for getting the channels used for host <-> guest/sidebar communication.
4434
// These currently rely on knowing the implementation detail of which order
4535
// the channels are created in.
@@ -132,6 +122,10 @@ describe('Sidebar', () => {
132122
};
133123

134124
beforeEach(() => {
125+
// Make `requestAnimationFrame` invoke its callback synchronously. rAF is
126+
// used to debounce some internal actions.
127+
sinon.stub(window, 'requestAnimationFrame').yields();
128+
135129
sidebars = [];
136130
containers = [];
137131

src/sidebar/test/bootstrap.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ globalThis.context ??= globalThis.describe;
1919
// Configure Enzyme for UI tests.
2020
configure({ adapter: new Adapter() });
2121

22-
// Unmount all UI components after each test.
2322
afterEach(() => {
23+
// Unmount all UI components after each test.
2424
unmountAll();
25+
// Restore all created mocks during a test, to free-up memory
26+
sinon.restore();
2527
});

0 commit comments

Comments
 (0)