实习生控制台报告没有将不同的套件分组
Intern console reported doesnt group the different suite
当 运行 使用控制台报告程序的实习客户端时,如果要测试的脚本不在应用程序文件夹下,报告输出不会显示任何套件分组。
实习生配置:
// 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');
}
});
});
控制台报告程序输出:
预期报告输出:
不允许使用像这样的相对模块 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
个条目。
- 将您的非法相对模块 ID 更改为有效的绝对模块 ID。
这看起来像这样(您没有提供确切的目录结构,所以我在猜测一些东西):
// 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,因为代码覆盖率报告是在物理文件级别而不是逻辑模块级别上工作的。
另请注意,这不是解决问题的唯一方法,而是一种相对 straight-forward 的方法。
当 运行 使用控制台报告程序的实习客户端时,如果要测试的脚本不在应用程序文件夹下,报告输出不会显示任何套件分组。
实习生配置:
// 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');
}
});
});
控制台报告程序输出:
预期报告输出:
不允许使用像这样的相对模块 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
个条目。 - 将您的非法相对模块 ID 更改为有效的绝对模块 ID。
这看起来像这样(您没有提供确切的目录结构,所以我在猜测一些东西):
// 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,因为代码覆盖率报告是在物理文件级别而不是逻辑模块级别上工作的。
另请注意,这不是解决问题的唯一方法,而是一种相对 straight-forward 的方法。