인프런 커뮤니티 질문&답변
작성자 없음
작성자 정보가 삭제된 글입니다.
노드버드 프로젝트에 테스트코드를 작성중에 있는데요!
작성
·
306
0
안녕하세요!
제가 노드버드 프로젝트에 테스트코드를 작성하고 싶어서
독학하는 중에 정말 안 풀리는게 있어서 문의드립니다..
기존에 스토어 만든 코드를 가지고 테스트용 스토어를 생성하고 있습니다.
아래는 제가 작성한 코드입니다..
import React from 'react'
import { render } from '@testing-library/react'
import wrapper from 'redux/store';
const Wrapper = ({ children }) => {
return <>{children}</>
};
const customRender = (ui, options) =>
render(ui, { wrapper: wrapper.withRedux(Wrapper), ...options })
export * from '@testing-library/react'
// override render method
export { customRender as renderRedux }
아래는 오류 내용입니다.
console.error
Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from
the file it's defined in, or you might have mixed up default and named imports.
Check the render method of withRedux(Wrapper).
at Wrapper ()
12 |
13 | const customRender = (ui, options) =>
> 14 | render(ui, { wrapper: wrapper.withRedux(Wrapper), ...options })
| ^
15 |
16 | export * from '@testing-library/react'
아무리 생각해도 떠오르지 않는데..혹시 조언해주실수 있으실까요 ㅜㅜ
답변 1
0
아뇨. redux/store에서 만드셨다는 게 무슨 말씀이신지 모르겠어서 그렇습니다. redux 라이브러리에 그런게 있지 않을 텐데요?
진짜 스토어랑 가짜 스토어는 또 무엇인가요..? 둘이 어떤 차이가 있는 거죠?
이거 testing-library로는 안 되고 e2e테스트 급으로 올리셔야 테스트 가능할 것 같습니다. nightwatch나 playwright같은 라이브러리로요.
참고로 스토어에 값이 변경되는지는 테스트 대상이 아닙니다. dispatch 하면 당연히 리듀서에 따라 스토어의 값이 변경되어야죠. 이건 당연한 겁니다. 당연한 것은 테스트할 필요가 없고요. 테스트하실 것은 e2e단이나 리듀서 단위 테스트 정도입니다.





wrapper을 왜 redux/store에서 import하신건가요??