尝试在打字稿项目中设置一些测试。但是出于某种原因,我在spec文件上得到了404(尽管我可以看到路径是正确的)。我的Karma配置文件中是否缺少某些内容?
module.exports = function(config) {
config.set({
basePath: ".",
frameworks: ["jspm", "jasmine"],
reporters: ["progress"],
browsers: ["PhantomJS"],
files: [
],
proxies: {
"/test/": "/base/test/",
"/src/": "/base/src/"
},
jspm: {
stripExtension: false,
loadFiles: [
"test/**/*.ts"
],
serveFiles: [
"src/**/*.ts"
]
},
preprocessors: {
"**/*.ts": ["typescript"]
},
typescriptPreprocessor: {
options: {
noResolve: false,
module: 'amd'
},
transformPath: function(path) {
return path.replace(/\.ts$/, '.js');
}
}
});
}
或者我的config.js文件?
System.config({
transpiler: "typescript",
paths: {
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*"
},
map: {
"typescript": "npm:typescript@1.8.10",
"github:jspm/nodelibs-os@0.1.0": {
"os-browserify": "npm:os-browserify@0.1.2"
},
"npm:os-browserify@0.1.2": {
"os": "github:jspm/nodelibs-os@0.1.0"
},
"npm:typescript@1.8.10": {
"os": "github:jspm/nodelibs-os@0.1.0"
}
}
});
答案 0 :(得分:0)
我有同样的问题,除了没有使用typescript-preprocessor,因为我希望JSPM来处理它。 在Karma + JSPM + Typescript - not found '.ts.js'和https://github.com/Larchy/karma-jspm-typescript-coverage
处的回购中查看我的问题基本上在我的jspm配置中添加了一个重复的包,以支持更高级别的业力
"app": {
"main": "app",
"format": "system",
"defaultExtension": "ts",
"meta": {
"*.ts": {
"loader": "ts"
}
}
},
"src/app": {
"main": "app",
"defaultExtension": "ts",
"meta": {
"*.ts": {
"loader": "ts"
}
}
}
并添加了代理到karma配置,就像你已经拥有的那样:
proxies : {
"/base/jspm_packages" : "/base/src/jspm_packages"
},