Looping on a protractor test with parameters

后端 未结 3 1168
既然无缘
既然无缘 2020-11-28 08:41

I have a set of smokescreen tests that are all pretty much identical. I would like to put them into a loop and loop at an array of parameters. However, the tests are runni

3条回答
  •  无人及你
    2020-11-28 09:01

    With some asynchronous code, you can solve this quite easily.

    instead of running it('description', function () { // my test }); use it('description', function (done) { // my test with a call to done() at the end }

    You can use this snippet as an example :

    for (var i = 0; i < 10; i++) {
      it('should work for ' + i, function (done) {
        setTimeout(done, 1000);
      });
    }  
    

    The expected output :

    ✓ should work for 0 (1000ms)
    ✓ should work for 1 (1001ms)
    ✓ should work for 2 (1001ms)
    ✓ should work for 3 (1001ms)
    ✓ should work for 4 (1001ms)
    ✓ should work for 5 (1001ms)
    ✓ should work for 6 (1002ms)
    ✓ should work for 7 (1001ms)
    ✓ should work for 8 (1001ms)
    ✓ should work for 9 (1002ms)
    

    Hope this helps.

提交回复
热议问题