当我试图用幻影运行业力测试时,如果我有另一个node_modules的例子的话,我就有问题了。
例如:
MyComponent
└── node_modules
└── examples
└── node_modules
└── src
└── app
└── app.component.ts
└── app.component.html
└── app.component.css
└── app.component.spec
└── app.module.ts
└── assets
└── index.html
└── angular-cli.json
└── karma.conf.js
└── package.json
└── src
└── app
└── my.component.ts
└── my.component.html
└── my.component.css
└── my.component.spec.ts
└── assets
└── base.spec.ts
└── karma.conf.js
└── package.jsonpackage.json
"dependencies": {
"@angular/common": "2.4.9",
"@angular/compiler": "2.4.9",
"@angular/core": "2.4.9",
"@angular/http": "2.4.9",
"@angular/platform-browser": "2.4.9",
"@angular/platform-browser-dynamic": "2.4.9",
"@angular/router": "3.4.9",
"@types/core-js": "0.9.36",
"@types/echarts": "0.0.5",
"angular-in-memory-web-api": "0.3.1",
"core-js": "2.4.1",
"echarts": "3.4.0",
"rxjs": "5.0.1",
"systemjs": "0.19.40",
"zone.js": "0.7.4"
},
"devDependencies": {
"@types/jasmine": "2.5.44",
"@types/node": "6.0.65",
"typescript": "2.2.1",
"jasmine-core": "2.5.2",
"karma": "1.5.0",
"karma-chrome-launcher": "2.0.0",
"karma-jasmine": "1.1.0",
"karma-typescript": "3.0.0-beta.1",
"karma-typescript-angular2-transform": "1.0.0-beta.5",
"karma-phantomjs-launcher": "1.0.4"
}karma.conf.js
module.exports = function(config) {
config.set({
frameworks: ["jasmine", "karma-typescript"],
files: [
{ pattern: "base.spec.ts" },
{ pattern: "src/app/**/*.+(ts|html)" }
],
exclude: [
'examples/**/*.js',
'examples/**/*.ts'
],
preprocessors: {
"**/*.ts": ["karma-typescript"]
},
karmaTypescriptConfig: {
bundlerOptions: {
entrypoints: /\.spec\.ts$/,
transforms: [
require("karma-typescript-angular2-transform")
]
},
coverageOptions: {
instrumentation: true
}
},
reporters: ["progress", "karma-typescript"],
browsers: ["Chrome"]
});
};当我在没有示例文件夹的情况下运行测试时,一切都正常,但是如果我尝试使用内部的示例来运行测试,而忽略它,它就无法工作。
我得到了下一个错误:
14 03 2017 11:15:07.881:错误因果报应:(/workspace/node_modules/typescript/lib/typescript.js:25122:46):TypeError:无法读取未定义的属性“名称”在/workspace/node_modules/typescript/lib/typescript.js:25146:21 at Map.forEach at mergeSymbol Map.forEach(原生)
发布于 2017-03-14 11:39:58
我发现你错了。
我必须排除预处理器配置中的文件夹:
`karmaTypescriptConfig: { bundlerOptions: { entrypoints: /\.spec\.ts$/, transforms: [ require("karma-typescript-angular2-transform") ] }, coverageOptions: { instrumentation: true }, exclude: ['examples'] },`https://stackoverflow.com/questions/42784849
复制相似问题