i've to testing ErrorBoundry, i've this code
import React, { Component } from 'react'
class ErrorBoundary extends Component {
constructor (props) {
super(props)
this.state = { hasError: false }
}
componentDidCatch (error, info) {
this.setState({ hasError: true })
}
render () {
if (this.state.hasError) {
return <h1>Something went wrong.</h1>
}
return this.props.children
}
}
export default ErrorBoundary
and i want to testing, now i've test when there an error, and everythings it's ok, but how i can write on test file i expect return this.props.children() or simulate something similar?
i use enzyme
Aucun commentaire:
Enregistrer un commentaire