我无法在使用打字稿编写的茉莉花单元测试中进行导入工作。 Chutzpah在import语句中抛出一个错误 - 在js中将其转换为define
import {fakeclass} from '../src/data-analysis/fakeclass';
我看到的错误是:
Error: ReferenceError: Can't find variable: define
否则测试会被发现并且运行正常。
我认为它必须与systemjs没有被chutzpah加载 - 是否有推荐的方法来设置它?
这是我的chutzpah.json文件
{
"Framework": "jasmine",
"TestHarnessReferenceMode": "Normal",
"TypeScriptModuleKind": "CommonJS",
"Compile": {
"Mode": "External",
"Extensions": [ ".ts" ],
"ExtensionsWithNoOutput": [ ".d.ts" ]
},
"References": [
{
"Includes": [ "src/*.ts" ],
"Excludes": [ "src/*.d.ts" ]
},
{
"Path": "./jspm_packages/system.src.js",
"IsTestFrameworkFile": true
},
{
"Path": "./jspm_packages/system-polyfills.src.js",
"IsTestFrameworkFile": true
},
{
"Path": "./config.js",
"IsTestFrameworkFile": true
}
],
"Tests": [
{
"Includes": [ "*/test/*.ts" ],
"Excludes": [ "*/test/*.d.ts" ]
}
]}
答案 0 :(得分:0)
我看了你给我的样本,并按照Chutzpah Angular2 sample中的模式开始工作。
<强> config.js 强>
System.config({
defaultJSExtensions: true,
transpiler: "babel",
babelOptions: {
"optional": [
"es7.decorators",
"runtime"
]
},
paths: {
"github:*": "jspm_packages/github/*",
"npm:*": "jspm_packages/npm/*"
},
map: {
}
});
<强> chutzpah.json 强>
{
"Framework": "jasmine",
"TestHarnessReferenceMode": "AMD",
"TestHarnessLocationMode": "SettingsFileAdjacent",
"Compile": {
"Mode": "External",
"Extensions": [ ".ts" ],
"ExtensionsWithNoOutput": [ ".d.ts" ]
},
"References": [
{
"Path": "./jspm_packages/system.src.js",
"IsTestFrameworkFile": true
},
{
"Path": "./jspm_packages/system-polyfills.src.js",
"IsTestFrameworkFile": true
},
{
"Path": "./config.js",
"IsTestFrameworkFile": true
}
],
"Tests": [
{
"Includes": [ "*/test/*.ts" ],
"Excludes": [ "*/test/*.d.ts" ]
}
],
"Server": {
"Enabled": true
}
}