Skip to content

Hush console errors for tests with invalid props #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 13, 2018

Conversation

shawnbot
Copy link
Contributor

This deploys a couple of strategically placed Jest mocks to silence console.error() for tests that render invalid props. Here's the pattern:

import {render} from '../utils/testing'

it('ignores invalid "foo" prop', () => {
  const hush = jest.spyOn(console, 'error').mockImplementation(jest.fn())
  expect(render(<MyComponent foo="bar" />).props.foo).toEqual(undefined)
  hush.mockRestore()
})

@shawnbot shawnbot mentioned this pull request Jul 10, 2018
5 tasks
Copy link

@emplums emplums left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@emplums emplums merged commit a64c1ec into release-0.0.9-beta Jul 13, 2018
@emplums emplums deleted the hush-console-error branch July 13, 2018 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants