2016-01-11 20 views
0

當使用控制檯記者運行實習生客戶端時,如果要測試的腳本未位於應用程序文件夾下,則報告輸出不會顯示任何套件分組。實習控制檯報告不分組不同套房

實習生配置:

// 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'); 
      } 
     }); 
    }); 

控制檯輸出記者:

enter image description here

預期報告輸出:

enter image description here

回答

1

升序使用這樣相對的模塊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'); 

相反,你應該做到以下幾點:

  1. 確保您basePath被配置爲指向包含你要去的所有模塊的目錄加載。
  2. 爲避免必須移動文件,請設置loaderOptions.packages條目。
  3. 將您的非法相關模塊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,因爲代碼覆蓋率報告適用於物理文件級別,而不是邏輯模塊級別。

另請注意,這不是解決問題的唯一方法,但它是一種相對直接的方法。