Skip to content
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

Assertions for propType warnings #399

Open
ezmiller opened this issue May 26, 2017 · 3 comments
Open

Assertions for propType warnings #399

ezmiller opened this issue May 26, 2017 · 3 comments
Labels

Comments

@ezmiller
Copy link

Have you ever thought about adding an assertion for propType warnings on a React component? One method for doing that in general is illustrated here, but wouldn't it be useful to have a dedicated assertion. In general, it seems to me that testing propType warnings is probably valuable, if one is taking their use seriously.

@gertsonderby
Copy link
Contributor

I like this idea. At best if you can test both positively or negatively, to ascertain that it will complain where you need it to, and leave it where it shouldn't.

@sunesimonsen
Copy link
Member

sunesimonsen commented May 27, 2017

It should be possible to create an assertion that mocks console.error.

I have earlier been thinking about doing property based testing based on the prop types using unexpected-check. The challenge is that the prop types won't reveal any information about themselves, so you need something like https://github.com/reactjs/react-docgen to get the prop types. But it would be very cool just to say that a component shouldn't crash for valid prop types.

@papandreou
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants