一个基本的Angular 2 cli应用程序包含一些karma-jasmine测试。
如果你运行npm install typemoq --save-dev
并将使用typemoq的内容添加到其中一个测试文件中。
import * as Moq from 'typemoq';
...
it('pointless test is pointless', async(() => {
let carMock = Moq.Mock.ofInstance(Car);
}));
class Car { ... }
当运行测试时,会出现以下错误。是否有人看到过使用typemoq与angular-cli或将依赖项引入angular-cli项目时发生的这种情况?问题在哪里?
类型错误:无法读取未定义的“substr”属性 在Function。 (C:\ Source \ ng-example-app \ foo \ node_modules \ webpack-sources \ node_modules \ source-map \ lib \ source-node.js:115:26) 在Array.forEach(本地) 在SourceMapConsumer_eachMapping [as eachMapping]中(C:\ Source \ ng-example-app \ foo \ node_modules \ webpack-sources \ node_modules \ source-map \ lib \ source-map-consumer.js:155:14) 在Function.SourceNode_fromStringWithSourceMap [as fromStringWithSourceMap]中(C:\ Source \ ng-example-app \ foo \ node_modules \ webpack-sources \ node_modules \ source-map \ lib \ source-node.js:80:24) 在SourceMapSource.node中(C:\ Source \ ng-example-app \ foo \ node_modules \ webpack-sources \ lib \ SourceMapSource.js:42:20) 在ReplaceSource.node中(C:\ Source \ ng-example-app \ foo \ node_modules \ webpack-sources \ lib \ ReplaceSource.js:66:29) 在C:\ Source \ ng-example-app \ foo \ node_modules \ webpack-sources \ lib \ ConcatSource.js:40:49 在Array.map(本地) 在ConcatSource.node中(C:\ Source \ ng-example-app \ foo \ node_modules \ webpack-sources \ lib \ ConcatSource.js:39:60) 在C:\ Source \ ng-example-app \ foo \ node_modules \ webpack-sources \ lib \ ConcatSource.js:40:49 在Array.map(本地) 在ConcatSource.node中(C:\ Source \ ng-example-app \ foo \ node_modules \ webpack-sources \ lib \ ConcatSource.js:39:60) 在C:\ Source \ ng-example-app \ foo \ node_modules \ webpack-sources \ lib \ ConcatSource.js:40:49 在Array.map(本地) 在ConcatSource.node中(C:\ Source \ ng-example-app \ foo \ node_modules \ webpack-sources \ lib \ ConcatSource.js:39:60) 在C:\ Source \ ng-example-app \ foo \ node_modules \ webpack-sources \ lib \ ConcatSource.js:40:49 在Array.map(本地) 在ConcatSource.node中(C:\ Source \ ng-example-app \ foo \ node_modules \ webpack-sources \ lib \ ConcatSource.js:39:60) 在ConcatSource.proto.sourceAndMap中(C:\ Source \ ng-example-app \ foo \ node_modules \ webpack-sources \ lib \ SourceAndMapMixin.js:28:18) 在CachedSource.sourceAndMap中(C:\ Source \ ng-example-app \ foo \ node_modules \ webpack-sources \ lib \ CachedSource.js:51:28) 在Compilation。 (C:\ Source \ ng-example-app \ foo \ node_modules \ webpack \ lib \ SourceMapDevToolPlugin.js:57:32) 在Array.map(本地) 在Compilation。 (C:\ Source \ ng-example-app \ foo \ node_modules \ webpack \ lib \ SourceMapDevToolPlugin.js:43:84) 在Array.forEach(本地) 在Compilation。 (C:\ Source \ ng-example-app \ foo \ node_modules \ webpack \ lib \ SourceMapDevToolPlugin.js:42:11) 在Compilation.applyPlugins(C:\ Source \ ng-example-app \ foo \ node_modules \ tapable \ lib \ Tapable.js:25:14) 在Compilation。 (C:\ Source \ ng-example-app \ foo \ node_modules \ webpack \ lib \ Compilation.js:616:10) 在Compilation.applyPluginsAsync(C:\ Source \ ng-example-app \ foo \ node_modules \ tapable \ lib \ Tapable.js:73:70) 在Compilation。 (C:\ Source \ ng-example-app \ foo \ node_modules \ webpack \ lib \ Compilation.js:612:9) 在Compilation.applyPluginsAsync(C:\ Source \ ng-example-app \ foo \ node_modules \ tapable \ lib \ Tapable.js:73:70) 在Compilation。 (C:\ Source \ ng-example-app \ foo \ node_modules \ webpack \ lib \ Compilation.js:608:8) 在Compilation.applyPluginsAsync(C:\ Source \ ng-example-app \ foo \ node_modules \ tapable \ lib \ Tapable.js:73:70) 在Compilation.seal(C:\ Source \ ng-example-app \ foo \ node_modules \ webpack \ lib \ Compilation.js:554:7) 在Compiler。 (C:\ Source \ ng-example-app \ foo \ node_modules \ webpack \ lib \ Compiler.js:468:16) 在C:\ Source \ ng-example-app \ foo \ node_modules \ tapable \ lib \ Tapable.js