【问题标题】:JSEncrypt is not defined coming when i am ruining ng test in angular 4当我在 Angular 4 中破坏 ng 测试时,未定义 JSEncrypt
【发布时间】:2017-10-09 10:44:54
【问题描述】:
rsaencryption(data) {
    var encrypt = new JSEncrypt();
}

我在 security.js 文件中这样使用,然后像下面这样导入 '声明 var JSEncrypt:任何;' 当我运行 ng test 时,我变得越来越喜欢

ReferenceError: JSEncrypt is not defined
at SecurityService.Array.concat.SecurityService.rsaencryption (http://localhost:9876/base/src/test.ts?5c53671ab11331130c37ebbdd5efa4f0d9bf5201:17318:23)
at SecurityService.Array.concat.SecurityService.doHmac (http://localhost:9876/base/src/test.ts?5c53671ab11331130c37ebbdd5efa4f0d9bf5201:17342:20)
at ApiPostman.Array.concat.ApiPostman.httpCall (http://localhost:9876/base/src/test.ts?5c53671ab11331130c37ebbdd5efa4f0d9bf5201:20310:48)
at otherBankAccountBenDetails.Array.concat.otherBankAccountBenDetails.countryListChanged (http://localhost:9876/base/src/test.ts?5c53671ab11331130c37ebbdd5efa4f0d9bf5201:62077:25)
at otherBankAccountBenDetails.Array.concat.otherBankAccountBenDetails.ngOnInit (http://localhost:9876/base/src/test.ts?5c53671ab11331130c37ebbdd5efa4f0d9bf5201:62046:14)
at checkAndUpdateDirectiveInline (http://localhost:9876/base/src/test.ts?5c53671ab11331130c37ebbdd5efa4f0d9bf5201:11196:19)
at checkAndUpdateNodeInline (http://localhost:9876/base/src/test.ts?5c53671ab11331130c37ebbdd5efa4f0d9bf5201:12619:17)
at checkAndUpdateNode (http://localhost:9876/base/src/test.ts?5c53671ab11331130c37ebbdd5efa4f0d9bf5201:12558:16)
at debugCheckAndUpdateNode (http://localhost:9876/base/src/test.ts?5c53671ab11331130c37ebbdd5efa4f0d9bf5201:13261:59)
at debugCheckDirectivesFn (http://localhost:9876/base/src/test.ts?5c53671ab11331130c37ebbdd5efa4f0d9bf5201:13202:13)**

【问题讨论】:

    标签: javascript angular unit-testing ionic2 angular-cli


    【解决方案1】:

    我们应该这样做

     var JSEncrypt = require('../../../assets/jsencrypt'); 
    

    声明 var JSEncrypt:any;

    【讨论】:

      猜你喜欢
      • 2018-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-03
      • 2014-05-21
      • 2023-02-17
      • 2019-01-05
      相关资源
      最近更新 更多