使用Jasmine和Karma进行测试,我正在使用该zxcvbn
库进行一些密码强度计算.当我尝试通过调用updateScore()
下面的函数来运行规范时,这会失败.
private updateScore(): void { const analysis = zxcvbn(this.password) this.score = analysis.score; this.comment = analysis.feedback.warning || analysis.feedback.suggestions[0]; }
在导入中,我正在做 import zxcvbn from 'zxcvbn';
这适用于应用程序,甚至在我构建和模拟时,但在规范中,它给了我这个错误:
FAILED TESTS: PasswordStrengthChecker ? should update the score when password changes Chrome 55.0.2883 (Mac OS X 10.11.6) TypeError: zxcvbn_1.default is not a function at PasswordStrengthChecker.updateScore (webpack:///src/components/password-strength-checker/password-strength-checker.ts:25:28 <- src/test.ts:93920:40) at PasswordStrengthChecker.ngOnChanges (webpack:///src/components/password-strength-checker/password-strength-checker.ts:20:9 <- src/test.ts:93916:14) at Object.(webpack:///src/components/password-strength-checker/password-strength-checker.spec.ts:27:13 <- src/test.ts:185997:18) at ZoneDelegate.invoke (webpack:///~/zone.js/dist/zone.js:232:0 <- src/test.ts:183822:26) at ProxyZoneSpec.onInvoke (webpack:///~/zone.js/dist/proxy.js:79:0 <- src/test.ts:130574:39) at ZoneDelegate.invoke (webpack:///~/zone.js/dist/zone.js:231:0 <- src/test.ts:183821:32) at Zone.run (webpack:///~/zone.js/dist/zone.js:114:0 <- src/test.ts:183704:43) at Object. (webpack:///~/zone.js/dist/jasmine-patch.js:102:0 <- src/test.ts:130289:34)
Martin Nuc.. 8
我在使用时遇到了这个问题
import linkifyStr from 'linkifyjs/string';
代替
import * as linkifyStr from 'linkifyjs/string';
我在使用时遇到了这个问题
import linkifyStr from 'linkifyjs/string';
代替
import * as linkifyStr from 'linkifyjs/string';