Closed
Description
react-testing-library
version: 5.0.0react
version: 16.4.2node
version: 8.11.3npm
(oryarn
) version: yarn 1.9.4
Relevant code or config:
const Component = props => {
if (props.throw) throw new Error('!!')
return <div>😀</div>
}
it('Throws an error when `props.throw === true`', () => {
const renderComponent = () => render(<Component throw />)
expect(renderComponent).toThrow('!!')
})
What you did:
I'm making a jest assertion that a component will throw an error under certain circumstances.
What happened:
While the test itself passes, the entire error shows up in the Jest output. Under other circumstances, jest suppresses errors that are thrown within a .toThrow()
assertion. (there's a test in the repo that shows this)
Reproduction:
https://github.com/good-idea/rtl-throws-error
Problem description:
Lots of unnecessary console output!
Suggested solution:
I haven't looked into how jest / RTL handles all of this and how it might be happening, but I'm happy to put together a PR. Just point me in the right direction!
Metadata
Metadata
Assignees
Labels
No labels