Adam Soliński
Adam Soliński

Reputation: 464

How to run same test file twice in protractor?

I have a situation where I want to run the same test file twice. Let's say I have a test1.js and login.js and I define my suite in such a way in configuration:

specs: [
    'test1.js',
    'login.js',
    'test1.js'
]

So as you can see I want to run test1.js twice, but protractor runs test1.js, login.js and then finishes. Do you have any idea how I can achieve this?

Regards Adam

Upvotes: 3

Views: 1695

Answers (2)

Dharam
Dharam

Reputation: 134

After reading all the above answers, i achieved this"running same test case multiple times" in most stupidest way :D

In a folder i copy pasted same testcase, 10 times and renamed them like below:

test1.js

test2.js

test3.js

.

.

test10.js

then in my config file // In your configuration file

specs: [

"./path to folder/**/TC*_spec.js"

]

It run the test 10 times :)

Upvotes: 0

Jmr
Jmr

Reputation: 12118

Protractor is globbing all of your specs file patterns to get the list of tests it should run, so there's no way to make this work via the list of specs. What I would do instead is use node's require to organize your tests:

// In your configuration file
specs: [
  'thetest.js'
]

// thetest.js
require('test1.js')();
require('login.js')();
require('test1.js')();

// test1.js
module.exports = function() {
  describe(...)
};

Upvotes: 4

Related Questions