>When testing, code that causes React state updates should be wrapped into act(...)
「Reactの状態更新を引き起こすコードはactでラップせよ」
今回の例でなぜrenderをラップしないで良いかというと、それが状態更新を引き起こさないからだ
この警告メッセージに含まれるサンプルコードではactの中身のコメントが// render componentsではなく/* fire events that update state */になっている
ドキュメントの側もこちらにあわせるべきでは?
full warning:
output
Warning: An update to MyComponent inside a test was not wrapped in act(...).
When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
This ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act
at MyComponent (/Users/nishio/keicho-webclient/src/MyComponent.tsx:8:29)
52 | // act(() => {
> 53 | setValue!(1);
| ^