Reactガイドを読んでいくその218
これは
Reactのガイドを読んでいく記事です。
ガイドのリンク
リファレンス
TestRenderer.act()
TestRenderer.actはtest-utilsのactヘルパーと同様にアプリケーション用のコンポーネントを準備する。
これを使ってTestRenderer.create と testRenderer.update の呼び出しをラップする場合は以下のような例がある。
import {create, act} from 'react-test-renderer'; import App from './app.js'; // The component being tested // render the component let root; act(() => { root = create(<App value={1}/>) }); // make assertions on root expect(root.toJSON()).toMatchSnapshot(); // update with some different props act(() => { root.update(<App value={2}/>); }) // make assertions on root expect(root.toJSON()).toMatchSnapshot();
今日はここまで