2017-12-17 3 views
0

私のコードは次のとおりです。componentWillMount機能でJestを使用して、反応ネイティブでcomponentWillMountをテストするにはどうすればよいですか?次のように

export default class { 
    componentWillMount=()=>{...} 
    render()=>(...return...) 
} 

を、私は、Web APIからいくつかのデータを取得します。今私はそれについて単体テストを作りたいと思っています。私は何をすべきか ? orz ...

+0

サンプルコードは役に立ちます。 @ Alen.KW –

答えて

0
componentWillMount() { 
    console.log(" ********** componentWillMount ******* "); 
    this.apiLogic 
    } 
    apiLogic =() => { 
    console.log("Fetch you Api "); 
    } 
1

componentWillMountをテストする必要はありません。反応することになります。あなたは、あなたがcomponentWillMountの中に入れたWeb APIリクエストをむしろテストするべきです。

この詳細については、stackoverflow questionをご確認ください。

関連する問題