As far as i know, you cannot call same script twice. We had similar issue and here's what I did to fix it - Use jasmine-data-provider
, create separate suites instead of scripts and loop through them using data provider. Here are the steps that i would follow -
- Install
jasmine-data-provider
npm package.
- Create two
describe
suites, one for choose_user
and the other for change_user
.
- Pass multiple data to these describe suites using
jasmine-data-provider
.
- Each time a
choose_user
- describe
runs, a change_user
- describe
also runs next to that.
Here's a sample code -
var dp = require('../node_modules/jasmine-data-provider'); //Install the npm package and provide its path
//Data provider object to store data that script uses
var objectDataProvider = {
'Test1': {user1: 'user_1'},
'Test2': {user1: 'user_2'},
'Test3': {user1: 'user_3'},
};
//Jasmine Data Provider function automatically loops through the tests - Test1, Test2, Test3
dp(objectDataProvider, function (data) {
describe('choose_user Test:', function(){
//Choose User specs that's applicable for one user
//To use the objectDataProvider data use - data.user1 all the time
});
describe('change_user Test:', function(){
//Change User specs that's applicable for one user
});
});
This script should run choose_user
and change_user
specs 3 times and then you can continue execution with rest of the scripts in pipe.
Hope it helps.