Skip to content

Commit 847996e

Browse files
committed
fix: ensure mocks are restored
1 parent 664d980 commit 847996e

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

src/__tests__/element-queries.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ test('return a proper error message when no label is found and there is an aria-
11861186
// https://github.com/testing-library/dom-testing-library/issues/723
11871187
it('gets form controls by label text on IE and other legacy browsers', () => {
11881188
// Simulate lack of support for HTMLInputElement.prototype.labels
1189-
const inputLabelsSpy = jest
1189+
jest
11901190
.spyOn(HTMLInputElement.prototype, 'labels', 'get')
11911191
.mockReturnValue(undefined)
11921192

@@ -1241,6 +1241,4 @@ it('gets form controls by label text on IE and other legacy browsers', () => {
12411241
expect(getByLabelText('6th one 6th two 6th three').id).toBe('sixth-id')
12421242
expect(getByLabelText('7th one').id).toBe('seventh-id')
12431243
expect(getByLabelText('8th one').id).toBe('eighth.id')
1244-
1245-
inputLabelsSpy.mockRestore()
12461244
})

tests/setup-env.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,5 @@ beforeAll(() => {
3737
})
3838

3939
afterAll(() => {
40-
console.warn.mockRestore()
40+
jest.restoreAllMocks()
4141
})

0 commit comments

Comments
 (0)