Testing with Jasmine and Karma,
I am using the zxcvbn
library to do some password strength calculations.
This fails when I try to run a spec on it, by calling the updateScore()
function below.
private updateScore(): void {
const analysis = zxcvbn(this.password)
this.score = analysis.score;
this.comment = analysis.feedback.warning || analysis.feedback.suggestions[0];
}
In the import, I am doing import zxcvbn from 'zxcvbn';
This works in the app, and even when I build and emulate, but in the spec, it gives me that error:
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.<anonymous> (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.<anonymous> (webpack:///~/zone.js/dist/jasmine-patch.js:102:0 <- src/test.ts:130289:34)
I had this problem when using
import linkifyStr from 'linkifyjs/string';
instead of
import * as linkifyStr from 'linkifyjs/string';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With