Skip to content

Commit d2f863b

Browse files
committed
Capture error output in test
1 parent 4e72bc1 commit d2f863b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

packages/react-router/modules/__tests__/Switch-test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ describe('A <Switch>', () => {
138138
it('throws with no <Router>', () => {
139139
const node = document.createElement('div')
140140

141+
spyOn(console, 'error')
142+
141143
expect(() => {
142144
ReactDOM.render((
143145
<Switch>
@@ -150,6 +152,11 @@ describe('A <Switch>', () => {
150152
</Switch>
151153
), node)
152154
}).toThrow(/You should not use <Switch> outside a <Router>/)
155+
156+
expect(console.error.calls.count()).toBe(1)
157+
expect(console.error.calls.argsFor(0)[0]).toContain(
158+
'The context `router` is marked as required in `Switch`'
159+
)
153160
})
154161
})
155162

0 commit comments

Comments
 (0)