vendredi 11 novembre 2016

Using tags with nightwatch - Special case

So I'm currently using Nightwatch.js to run some tests on a web platform. We have nightwatch configured with Saucelabs so we can run multiple tests at the same time and see recordings of each test. However, our test cases are split up into multiple files rather than multiple steps in a single file.

Since sauce labs doesn't like to run multiple files within a single browser session, we had to do a little hack:

extend = function(target) {
    var sources = [].slice.call(arguments, 1);
    sources.forEach(function (source) {
    for (var prop in source) {
        target[prop] = source[prop];
        }
    });
    return target;
}


 require("./login.spec.js");
 module.exports = extend(module.exports,login);

 require("./getCustomLink.js");
 module.exports = extend(module.exports,getCustLink);

Essentially, you use 'require' and the file path the test and just add on to your current test module. So if the test doesn't end in "browser.end()" then it will continue to run through the tests in the order specified. My question is: I'm going to be having multiples of these kinds of files with different orders of test cases for different cases. How exactly would I add a '@tags' to this so I can just call the tag when running:

npm test --tags @tagHere

and it will just run the master file and the order of tests I specified?

Aucun commentaire:

Enregistrer un commentaire