0

I want to test run all my mocha test cases for an array of different users. All test cases will run for every user in the array. I am currently maintaining the list of users in an array in a config.

How to achieve this using webdriverio and mocha?

Rahul
  • 645
  • 1
  • 9
  • 21

1 Answers1

2

Mocha does support it by default.

But you can update your test suite to support it, basically it will run tests in a loop:

describe('data-driven tests', function () {
  var runs = [
    {it: 'user 1', options: {...}},
    {it: 'user 2', options: {...}},
  ];

  before(function () {
    ...
  });

  runs.forEach(function (run) {
    it('test functionality for ' + run.it, function () {
      ...
    });
  });
});
dmle
  • 3,498
  • 1
  • 14
  • 22