带有 Browserify 和 TypeScript 模块的 Wallaby
Wallaby with Browserify and TypeScript modules
我正在尝试让 Wallaby 使用 TypeScript 应用程序,使用 Browserify 和 Wallabify。但是我运行小袋鼠的时候输出No failing tests, 0 passing
,所有测试指标都是灰色的
文件app/spec.setup.ts
负责加载节点模块依赖,如chai、sinon和应用程序的主模块。 app/spec.util.ts
提供了一些助手,由单独的规范文件导入。
module.exports = function() {
var wallabify = require('wallabify');
var wallabyPostprocessor = wallabify({
entryPatterns: [
'app/spec.setup.ts',
'app/src/**/*.spec.ts'
]
}
);
return {
files: [
{pattern: 'app/spec.setup.ts', load: false, instrument: false},
{pattern: 'app/spec.util.ts', load: false, instrument: false},
{pattern: 'app/src/**/*.ts', load: false},
{pattern: 'app/src/**/*.spec.ts', ignore: true}
],
tests: [
{pattern: 'app/src/**/*.spec.ts', load: false}
],
testFramework: 'mocha',
postprocessor: wallabyPostprocessor,
bootstrap: function (w) {
// outputs test file names, with .ts extensions changed to .js
console.log(w.tests);
window.__moduleBundler.loadTests();
}
};
};
有趣的是,我没有从更改 entryPatterns
中得到任何反馈,即使将其设置为空数组或无效文件名。结果还是一样。只有当我 完全 删除它时,我才会收到诸如 Can't find variable: sinon
.
之类的错误
我还认为 entryPatterns
列表可能需要编译后的文件名,即 .js
而不是 .ts
扩展名。但是,当我这样做时,我在 spec.setup.ts
.
上得到 Postprocessor run failure: 'import' and 'export' may appear only with 'sourceType: module'
我不知道为 TypeScript 编译配置 Wallabify 的正确方法是什么,我在网上找不到任何完整的示例,所以我很感激任何提示。
P.S。以我目前的 Whosebug 声誉,我无法添加两个新标签:wallaby
和 wallabify
。谁能帮我一个忙,请添加这两个标签。
因为 TypeScript compiler renames files to .js
and applied before wallabify,您需要像这样更改输入模式才能使其正常工作:
entryPatterns: [
'app/spec.setup.js',
'app/src/**/*.spec.js'
]
我正在尝试让 Wallaby 使用 TypeScript 应用程序,使用 Browserify 和 Wallabify。但是我运行小袋鼠的时候输出No failing tests, 0 passing
,所有测试指标都是灰色的
文件app/spec.setup.ts
负责加载节点模块依赖,如chai、sinon和应用程序的主模块。 app/spec.util.ts
提供了一些助手,由单独的规范文件导入。
module.exports = function() {
var wallabify = require('wallabify');
var wallabyPostprocessor = wallabify({
entryPatterns: [
'app/spec.setup.ts',
'app/src/**/*.spec.ts'
]
}
);
return {
files: [
{pattern: 'app/spec.setup.ts', load: false, instrument: false},
{pattern: 'app/spec.util.ts', load: false, instrument: false},
{pattern: 'app/src/**/*.ts', load: false},
{pattern: 'app/src/**/*.spec.ts', ignore: true}
],
tests: [
{pattern: 'app/src/**/*.spec.ts', load: false}
],
testFramework: 'mocha',
postprocessor: wallabyPostprocessor,
bootstrap: function (w) {
// outputs test file names, with .ts extensions changed to .js
console.log(w.tests);
window.__moduleBundler.loadTests();
}
};
};
有趣的是,我没有从更改 entryPatterns
中得到任何反馈,即使将其设置为空数组或无效文件名。结果还是一样。只有当我 完全 删除它时,我才会收到诸如 Can't find variable: sinon
.
我还认为 entryPatterns
列表可能需要编译后的文件名,即 .js
而不是 .ts
扩展名。但是,当我这样做时,我在 spec.setup.ts
.
Postprocessor run failure: 'import' and 'export' may appear only with 'sourceType: module'
我不知道为 TypeScript 编译配置 Wallabify 的正确方法是什么,我在网上找不到任何完整的示例,所以我很感激任何提示。
P.S。以我目前的 Whosebug 声誉,我无法添加两个新标签:wallaby
和 wallabify
。谁能帮我一个忙,请添加这两个标签。
因为 TypeScript compiler renames files to .js
and applied before wallabify,您需要像这样更改输入模式才能使其正常工作:
entryPatterns: [
'app/spec.setup.js',
'app/src/**/*.spec.js'
]