There are times when our React components use lifecycle methods like componentDidMount
. In this lesson we will make sure that we write tests to make sure that these methods are called. This includes testing that our component utilizes componentWillReceiveProps
correctly.
I am using typescript, it is throwing error for ..componentDidMount.mock.calls .. .
The error is Property 'mock' does not exist on type '() => void'.
It seems is not a typesafe operation. Is there a workaround for this? Found https://jestjs.io/docs/en/mock-function-api#mockfnmockimplementationfn