if I shallow render a component called MyComponent, whose render function looks like:
render() {
return(
<MySubComponent /> // purposely omitting required prop value
)
}
and MySubComponent.propTypes look like:
{
value: React.propTypes.string.isRequired
}
i only get a propType warning the first time I run shallow(<MyComponent />) in a jest test. The second time i run shallow(<MyComponent />) I do not get a propType warning.
It should give me a propType warning every time I run shallow(<MyComponent />) if MySubComponent does not have valid propTypes.
Indeed, it should. Can you verify if that's related to jest by trying a different framework? Can you share your test file?
This is expected behavior, React dedupes these messages so they are only logged once, no matter how many times the component is rendered.
ahh that explains it. i appreciate the point out in source code. thanks guys! @ljharb @aweary