Unit-Testing-Vue2
Unit-Testing-Vue2 copied to clipboard
Error: Cannot read property 'text' of undefined
Hi, I get an error when testing FlushPromises :
Cannot read property 'text' of undefined
The app is working fine, it runs correctly, I've even added a line to display <MessageDisplay /> in the AppHeader.vue to make sure the json-server is up and running.
The beginning of the log:
console.error node_modules/vue/dist/vue.runtime.common.dev.js:621
[Vue warn]: Error in render: "TypeError: Cannot read property 'text' of undefined"
found in
---> <Anonymous>
<Root>
console.error node_modules/vue/dist/vue.runtime.common.dev.js:1884
TypeError: Cannot read property 'text' of undefined
Same here
Hi. I've added this code after jest.mock() call:
beforeEach(() => { jest.clearAllMocks(); //todo don't forget to clear all mocks before each test! })
and it seemed to clear that error.