[英]Cannot read property 'salt' of null in CryptoJS.AES.decrypt
i am testing my application using jest on vuejs.我正在 vuejs 上使用 jest 测试我的应用程序。 I am getting an error as TypeError: Cannot read property 'salt' of null
when I decrypt a string using crypto-js
.当我使用crypto-js
解密字符串时,我收到一个错误,如TypeError: Cannot read property 'salt' of null
。
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当测试运行时,它会运行checkingRoutes
函数
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如何解决@vue/test-utils 上的问题
I solved the issue by mocking the exact function here is the example below我通过模拟这里的确切功能解决了这个问题是下面的例子
globalFunctions => // helper or defined as global
DecKey => // exact function that trigger to solve the issue
const decryptData = jest.spyOn(globalFunctions, "DecKey");
decryptData.mockImplementation(() => "['passing_values']");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.