Angular 2 unit testing - getting error Failed to load 'ng:///DynamicTestModule/module.ngfactory.js'

前端 未结 10 2375
执念已碎
执念已碎 2020-12-23 11:04

I have angular 2 webpack application, all webpack,karma configuration created as per angular.io webpack guide. I am not using aot. I am writing jasmine unit test spec to te

10条回答
  •  -上瘾入骨i
    2020-12-23 11:47

    To find out what's really causing the error, disable source maps:

    For angular-cli >= v6.x:

    ng test --source-map=false
    

    For angular-cli v1.x:

    ng test -sm=false
    

    You will then see a better error, e.g. "Cannot read property 'x' of undefined" in the actual source file that's causing the error. For some reason, there's a bug with sourcemaps right now in testing, and you just get this cryptic error.

提交回复
热议问题