Enzyme: missing shallow propTypes warning for a subcomponent

Created on 20 Jan 2017  路  3Comments  路  Source: enzymejs/enzyme

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.

invalid question

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings