根据文档,我们可以有测试套件的组-子组,但它们只存在于一个文件中,如下所示
describe('Main Group - Module 1', function () {
beforeEach(function () {
module('app');
});
describe('sub group - 1', function () { // Sub group
// specs goes here
});
describe('sub group - 2', function () { // Sub group
// specs goes here
});
});
如果我想将 sub group -1 和 sub group -2 保存在两个不同的文件中,我如何将这两个子组分组到 Main Group - Module 中?
谢谢
最佳答案
我的用例是 Jasmine-Node,所以 require
语句对我来说没有任何区别。如果您正在使用基于浏览器的 Jasmine,则必须使用 RequireJS对于这个解决方案。或者,如果没有 require 语句,您可以使用 this example from the Jasmine repo issues .
file1.js
module.exports = function() {
describe('sub group - 1', function () { // Sub group
// specs goes here
});
};
file2.js
module.exports = function() {
describe('sub group - 2', function () { // Sub group
// specs goes here
});
};
file3.js
var subgroup1 = require( './file1.js' );
var subgroup2 = require( './file2.js' );
describe('Main Group - Module 1', function () {
beforeEach(function () {
module('app');
});
subgroup1();
subgroup2();
});
关于javascript - 当不同文件中存在测试时,如何在 jasmine 中对测试套件进行分组?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30389516/