简体   繁体   English

无法读取 CryptoJS.AES.decrypt 中的 null 属性“盐”

[英]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.

相关问题 TypeError:无法读取null的属性'forgotPassword' - TypeError: Cannot read property 'forgotPassword' of null jsdom:无法读取null的属性'_location' - jsdom: Cannot read property '_location' of null Jasmine - TypeError:无法读取null的属性'spyOn' - Jasmine - TypeError: Cannot read property 'spyOn' of null TypeError:无法读取null的属性“ user” - TypeError: Cannot read property 'user' of null Ember测试:无法读取null的属性'createRecord' - Ember Testing: Cannot read property 'createRecord' of null 在Karma单元测试中出现错误'无法读取属性'triggerEventHandler'为null' - Error 'Cannot read property 'triggerEventHandler' of null' in Karma unit testing ES6 jsdom无法读取null的属性“ innerHTML” - ES6 jsdom cannot read property 'innerHTML' of null Angular 测试 - 在 Karma 上获取“TypeError: Cannot read property 'textContent' of null” - Angular test - Getting “TypeError: Cannot read property 'textContent' of null” on Karma “Uncaught TypeError:使用带有Karma的RequireJS”无法读取null的属性'...' - “Uncaught TypeError: Cannot read property '…' of null” using RequireJS with Karma Jasmine为Angular 2单元测试提供Cannot read属性'getXHR'为null - Jasmine gives Cannot read property 'getXHR' of null for Angular 2 unit test
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM