22 01 회고 - ChoDragon9/posts GitHub Wiki

업무 티켓 내용 작성

userEvent.type 사용 후 act 사용 경고

에러 로그

console.error node_modules/react-dom/cjs/react-dom.development.js:88
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 */

해결 방법

https://testing-library.com/docs/react-testing-library/faq/

waitFor 사용.

await waitFor(() => expect().toBe());