当使用控制台报告运行实习生客户端时,如果要测试的脚本不在app文件夹下,则报表输出不会显示任何套件分组。
实习生Config:
// Non-functional test suite(s) to run in each browser
suites: [ 'tests/unit/hello' ],单元测试:
define(function (require) {
var registerSuite = require('intern!object');
var assert = require('intern/chai!assert');
var hello = require('../../../Source/MyProject/dist/hello'); // "app/hello" would show suite grouping in the console output
registerSuite({
name: 'hello',
greet: function () {
assert.strictEqual(hello.greet('Hussein'), 'Hello, Hussein!',
'hello.greet should return a greeting for the person named in the first argument');
}
});
});控制台报告输出:

预期报告的产出:

发布于 2016-01-12 01:22:55
不允许在模块ID根之上使用类似于此的相对模块ID。此操作的结果未定义:
// from `tests/unit/hello`, this relative module ID
// resolves to "../Source/MyProject/dist/hello", which is
// not valid
var hello = require('../../../Source/MyProject/dist/hello');相反,您应该执行以下操作:
basePath被配置为指向包含将要加载的所有模块的目录。loaderOptions.packages条目。这应该是这样的(您没有提供确切的目录结构,所以我猜是这样的):
// intern config
{
basePath: '/path/to/root',
loaderOptions: {
packages: [
{ name: 'tests', location: 'tests' },
{ name: 'app', location: 'Source/MyProject/dist' }
}
}
}
// tests/unit/hello.js
...
var hello = require('app/hello');
...注意,最终的覆盖率输出将显示文件名,而不是模块ID,因为代码覆盖率报告工作在物理文件级别,而不是逻辑模块级别。
还要注意的是,这不是解决问题的唯一方法,而是一种相对直截了当的方法。
https://stackoverflow.com/questions/34730977
复制相似问题