6
universal-cookie
을 사용하여 로컬 저장소에 저장 한 다음 저장소로 파이프합니다. 나는 농담 테스트 스위트를 실행하면반응 연기 테스트 (Create-react-app) 중에 "쿠키 헤더 또는 개체 누락"오류가 발생했습니다.
class App extends Component {
componentDidMount() {
// if a cookie is present, save the value in the store for use communication
// with the server. If the cookie is undefined, the user is redirected to the login page.
// Redirection is handled by router.
const userNameInCookie = cookies.get('userName');
if (userNameInCookie) {
this.props.dispatch(actions.setUserNameFromCookie(userNameInCookie));
}
}
render() {
return (
<div>
<div className="header">
<h2 className="header-title">Traveler</h2>
</div>
{this.props.children}
</div>
);
}
}
는 매 시험이 오류
FAIL src/test/UserCreateForm.test.js
● Test suite failed to run
Missing the cookie header or object
at new Cookies (node_modules/universal-cookie/lib/Cookies.js:35:15)
at Object.<anonymous> (src/actions/index.js:4:17)
at Object.<anonymous> (src/reducers/index.js:1:258)
at Object.<anonymous> (src/store.js:4:40)
at Object.<anonymous> (src/test/UserCreateForm.test.js:7:40)
at handle (node_modules/worker-farm/lib/child/index.js:41:8)
at process.<anonymous> (node_modules/worker-farm/lib/child/index.js:47:3)
at emitTwo (events.js:106:13)
at process.emit (events.js:194:7)
at process.nextTick (internal/child_process.js:766:12)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
나는 또한 효소와 연기 테스트를 시도 실패,하지만 난 같은 오류가 발생합니다. 코드는 내가 원하는대로 정확하게 동작하므로, universal-cookie
은 테스트와 잘 어울리지 않는다고 생각합니다.
아이디어가 있으십니까? 감사합니다.