我有一个离子型应用程序,我介绍了使用业力+茉莉花进行测试。此外,我在测试中使用了打字记录预处理器。
我有以下依赖项,除了前两个之外,所有的依赖项都必须添加以进行测试:
"devDependencies": {
"@ionic/app-scripts": "1.0.0",
"typescript": "2.0.9"
"@types/core-js": "^0.9.35",
"@types/jasmine": "^2.5.41",
"angular-cli": "^1.0.0-beta.26",
"jasmine-core": "^2.5.2",
"karma": "^1.4.0",
"karma-jasmine": "^1.1.0",
"karma-safari-launcher": "^1.0.0",
"karma-typescript": "^2.1.6",
"reflect-metadata": "^0.1.9",
},tsconfig.json
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": [
"dom",
"es2015"
],
"module": "es2015",
"moduleResolution": "node",
"sourceMap": true,
"target": "es5"
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules"
],
"compileOnSave": false,
"atom": {
"rewriteTsconfig": false
}
}这是我的karma.conf.js文件:
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ["jasmine", "karma-typescript"],
files: [
{pattern: "src/**/*.spec.ts"},
{pattern: "test/**/*.spec.ts"},
{pattern: 'node_modules/reflect-metadata/Reflect.js', included: true, watched: true}
],
preprocessors: {
"**/*.ts": ["karma-typescript"], // *.tsx for React Jsx
},
reporters: ["progress", "karma-typescript"],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['Safari'],
singleRun: true,
concurrency: Infinity
})
}问题所在
现在,使用以下命令可以很好地进行测试:
./node_modules/karma/bin/karma start karma.conf.js 但是,当我现在运行ionic serve时,我会得到非常神秘的错误消息,如下所示:
我的看法是,devDependencies破坏了应用程序其余部分的“加载路径”。所以我想知道我的应用程序是如何重新开始工作的。
发布于 2017-01-27 17:37:51
问题是,您使用的是es2015定义和core-js定义。
核心-JS提供多填充,因此与TypeScript ES6+标准定义相冲突。
删除@types/core-js并将karmaTypescriptConfig: { compilerOptions: { lib: ['dom', 'es2015'] } }添加到karma.conf.js中,以使Karma类型记录使用es2015定义。
https://stackoverflow.com/questions/41898762
复制相似问题