Skip to content

Commit e6ff467

Browse files
author
Kent C. Dodds
committed
some improvements
1 parent d55411b commit e6ff467

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/__tests__/error-boundary-01.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import {render, fireEvent} from '@testing-library/react'
33
import {reportError as mockReportError} from '../api'
44
import {ErrorBoundary} from '../error-boundary'
55

6-
jest.mock('../api', () => {
7-
return {
8-
reportError: jest.fn(() => Promise.resolve({success: true})),
9-
}
10-
})
6+
jest.mock('../api')
117

128
beforeEach(() => {
139
// when the error's thrown a bunch of console.errors are called even though
@@ -17,6 +13,7 @@ beforeEach(() => {
1713
})
1814

1915
afterEach(() => {
16+
jest.clearAllMocks()
2017
console.error.mockRestore()
2118
})
2219

@@ -29,6 +26,7 @@ function Bomb({shouldThrow}) {
2926
}
3027

3128
test('calls reportError and renders that there was a problem', () => {
29+
mockReportError.mockResolvedValueOnce({success: true})
3230
const {container, rerender, getByText} = render(
3331
<ErrorBoundary>
3432
<Bomb />

0 commit comments

Comments
 (0)