Vue.js 장치 테스트 중 vuex 저장소 업데이트 오류
테스트에서 커밋을 사용하여 vuex 상태 값을 변경한 다음 변경 사항에 따라 렌더링되어야 하는 요소가 있는지 확인하려고 합니다.이런 거.
it('should render error state if no stores', () => {
wrapper.store.commit('stores/updateLoadingStores', false);
wrapper.store.commit('stores/updateStores', []);
expect(wrapper.find('error-state-stub').exists()).toBe(true);
});
대신 다음 오류가 발생합니다. '''StoresStep » 스토어가 없으면 오류 상태를 렌더링해야 합니다.
TypeError: Cannot read property '_isDestroyed' of undefined
31 | const mutationName = `${prefix}${_upperFirst(name)}`;
32 | acc[mutationName] = (state, value) => {
> 33 | state[name] = value;
| ^
34 | };
35 | return acc;
36 | }, {});
at destroy (node_modules/vue/dist/vue.runtime.common.dev.js:3151:28)
at invokeDestroyHook (node_modules/vue/dist/vue.runtime.common.dev.js:6088:59)
...
```
이것이 불평하는 기능은 특정 모듈에 값을 설정하기 위한 래퍼입니다.실제 오류 참조 -TypeError: Cannot read property '_isDestroyed' of undefined
에서 오는vue.runtime.common.dev.js
부에인 줄 알았어요.$nextTick() 관련이 있지만 아닌 것 같습니다.
wrapper.store
부품은 부품을 장착하고 관련된 모든 것을 한 곳에서 사용할 수 있도록 작성한 유틸리티입니다.
도움을 주시면 감사하겠습니다.
마침내 저는 그것을 알아냈습니다.그 문제는 명백하지 않았습니다.저는 원래의 문제에 대한 단서를 찾기 위해 vue.js 소스 코드를 조사해야 했습니다.기본적으로, 이 vue-test-sys 문제는 부분적으로 그것을 설명합니다 - https://github.com/vuejs/vue-test-utils/issues/52
가장 큰 문제는 오류가 당신을 과도기로 연결시키지 않는다는 것이었습니다. 그래서 저는 잘못된 방향을 보고 있었습니다.
그리고 솔루션은 단순하고, 단순한 전환입니다 :)
VueTestUtils.config.stubs['transition'] = true;
언급URL : https://stackoverflow.com/questions/57189442/vue-js-unit-testing-updating-vuex-store-error
'source' 카테고리의 다른 글
Junit java.lang.NoSuchMethodError: org.junit.주피터.api.combersExtensionContext.get필수 테스트 인스턴스() (0) | 2023.07.13 |
---|---|
R에서 디버깅을 위한 일반적인 제안 사항 (0) | 2023.07.08 |
긴 포인터가 무엇입니까? (0) | 2023.07.08 |
POST를 사용하여 Axios Excel 파일을 다운로드하면 파일이 손상됨 (0) | 2023.07.08 |
Mongodb 그룹 및 정렬 (0) | 2023.07.08 |