首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >实习生控制台报告不对不同的套件进行分组

实习生控制台报告不对不同的套件进行分组
EN

Stack Overflow用户
提问于 2016-01-11 21:00:23
回答 1查看 37关注 0票数 0

当使用控制台报告运行实习生客户端时,如果要测试的脚本不在app文件夹下,则报表输出不会显示任何套件分组。

实习生Config:

代码语言:javascript
运行
复制
// Non-functional test suite(s) to run in each browser
suites: [ 'tests/unit/hello' ],

单元测试:

代码语言:javascript
运行
复制
 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');
            }
        });
    });

控制台报告输出:

预期报告的产出:

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-01-12 01:22:55

不允许在模块ID根之上使用类似于此的相对模块ID。此操作的结果未定义:

代码语言:javascript
运行
复制
// 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');

相反,您应该执行以下操作:

  1. 确保您的basePath被配置为指向包含将要加载的所有模块的目录。
  2. 为了避免在文件中移动,请设置loaderOptions.packages条目。
  3. 将非法的相对模块ID更改为有效的绝对模块ID。

这应该是这样的(您没有提供确切的目录结构,所以我猜是这样的):

代码语言:javascript
运行
复制
// 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,因为代码覆盖率报告工作在物理文件级别,而不是逻辑模块级别。

还要注意的是,这不是解决问题的唯一方法,而是一种相对直截了当的方法。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34730977

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档