How to group test suites in jasmine when tests exist in different files?

According to the documentation, we can have subgroups of test suites, but they exist in only one file, as shown below

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

If I want to save subgroup -1 and subgroup -2 in two different files, how can I group these two subgroups in the main group - the module?

thanks

+5
source share
2 answers

You can do the following:

file1.js

 describe('Main Group - Module 1', function () { beforeEach(function () { module('app'); }); describe('sub group - 1', function () { // Sub group // specs goes here }); }); 

file2.js

 describe('Main Group - Module 1', function () { beforeEach(function () { module('app'); }); describe('sub group - 2', function () { // Sub group // specs goes here }); }); 

Pay attention to the same parent name.

+2
source

My use case for this is Jasmine-Node, so the require statements have no meaning to me. If you are using browser-based Jasmine, you will need to use RequireJS for this solution. Alternatively, without any statements, you can use this example from Jasmine's repository 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(); }); 
+2
source

All Articles