Skip to content

Assertions for propType warnings #399

Open

Description

@ezmiller

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.

Activity

  1. gertsonderby commented on May 26, 2017

    @gertsonderby
    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.

  2. sunesimonsen commented on May 27, 2017

    @sunesimonsen
    Member

    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.

  3. papandreou commented on Jan 20, 2019

    @papandreou
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions