warning 이 뜨는 이유가 뭔지 모르겠어요..
412
작성한 질문수 4
console.error Warning: An update to Type 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 Type (C:\git\inflearn\react-shop-test\src\pages\OrderPage\Type.js:8:17) at div at div at OrderPage at OrderContextProvider (C:\git\inflearn\react-shop-test\src\contexts\OrderContext.js:21:43) at div at App
19 | try {
20 | let response = await axios.get(`http://localhost:5000/${orderType}`); > 21 | setItems(response.data);
| ^
22 | } catch (error) {
23 | setError(true);
24 | }
at printWarning (node_modules/react-dom/cjs/react-dom.development.js:86:30)
at error (node_modules/react-dom/cjs/react-dom.development.js:60:7)
at warnIfUpdatesNotWrappedWithActDEV (node_modules/react-dom/cjs/react-dom.development.js:27589:9)
at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom.development.js:25508:5)
at setItems (node_modules/react-dom/cjs/react-dom.development.js:17527:7
at loadItems (src/pages/OrderPage/Type.js:21:13)
안녕하세요 강사님.
react context 강의를 들으면서 테스트를 진행하고 있는데,
이런 warning 이 발생합니다. ㅠㅠ
act라는 wrapper를 감싸주라고 하는데,
강의에서는 이런 경고 문구가 안나오는것 같아서..
제가 잘못한 부분이 있는건지 도움 부탁드립니다..
test 자체는 다 success가 뜨는데 발생하는 warning 입니다..!
답변 1
제공해주신 코드를 vscode에서 켜도 eslint가 안됩니다.
0
282
2
ERROR
0
210
1
테스트 시간을 단축할 수 있는 방법에 대하여 문의드립니다.
0
362
1
useState 배열값 변경의 경우 테스트 멈춤
0
413
1
test was not wrapped in act관련 질문
0
292
2
안녕하세요! 로딩 상태 테스트에 관련된 질문입니다.
0
395
1
강의 관련 내용 github 업로드 질문
0
308
1
이미지가 안보인다 하셔서 다시 질문드립니다.
0
415
2
Test Fail이 발생합니다 ㅠㅠ
0
357
1
스타일 컴포넌트 테스트 방법
0
440
1
msw 에러
0
635
1
toHaveTextContent 에러
0
447
1
msw안돼는사람
0
582
1
This could be because the text is broken up by multiple elements. 에러
0
1717
2
Type.test.js파일에 궁금한점이 생겼습니다
0
352
1
28강 수강 중 JSX 작성 방법에 대해 궁금해져서 질문 남깁니다!
0
400
1
toHaveTextContent 에서 에러가 자꾸 나는데 아무리 찾아도 잘 모르겠습니다.
0
612
2
aria-*
0
441
1
This XML file does not appear to have any style information associated with it. The document tree is shown below. 에러
1
14126
1
컴포넌트 props내려줄때 코드는 어떻게 해야하나요
0
249
0
es6 jest 미지원 오류 문의
0
860
1
test 여러 개 실행 - fail 발생
0
292
1
useMemo
0
284
1
axios 1.1.2 버전 issue ( SyntaxError: Cannot use import statement outside a module)
4
2227
5





