i am testing my application using jest on vuejs. I am getting an error as TypeError: Cannot read property 'salt' of null
when I decrypt a string using crypto-js
.
test("DASHBOARD ACCESS PERMISSION", async () => {
let wrapper = mount(Dashboard, {
stubs: ["router-link", "router-view"],
vuetify,
router,
localVue,
});
wrapper.vm.checkingRoutes();
});
when the test is run it runs checkingRoutes
function
let key = 'abcd'
var bytes = CryptoJS.AES.decrypt('encripted key is here', key);
var data = bytes.toString(CryptoJS.enc.Utf8);
console.log(data)
how to solve the issue on @vue/test-utils
I solved the issue by mocking the exact function here is the example below