0

While running Angular-unit test, using chrome browser, ended up with the error as

TypeError: userAgent.toLowerCase is not a function
    at _isAndroid (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/forms/fesm2015/forms.mjs:176:43)
    at new DefaultValueAccessor (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/forms/fesm2015/forms.mjs:227:38)
    at NodeInjectorFactory.factory (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/forms/fesm2015/forms.mjs:254:1)
    at getNodeInjectable (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:3565:44)
    at instantiateAllDirectives (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:10318:27)
    at createDirectivesInstances (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:9647:5)
    at ɵɵelementStart (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:14561:9)
    at templateFn (ng:///TodaysMarketMoversComponent.js:397:66)
    at executeTemplate (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:9618:9)
    at renderView (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:9421:13)

Most wondering/confusing part to me- toLowerCase function has never been used through out the component/spec file.

Bhupendra Kumar
  • 179
  • 3
  • 7

1 Answers1

0

It looks like the userAgent is being checked by the @angular/forms lib and has been deleted or not provided at all for some reason.

If it's not your code that's changing the userAgent then it's probably some third-party script.

If I were you I'd start with the latest additions in terms of libraries and dependencies and peel them back until I get a unit test running. That will give the clue.

Georgi
  • 31
  • 6