I am currently working on creating a web app that allows me to run Nightwatch tests from a graphic interface. Right now I can run all my tests with a post request from my web app I am using Nightwatch Programmatic API. My question is can I chose the folder of tests I want to run from a post request, here is my code, Thank you.
router.post('/exec', function (req, res) {
Nightwatch.cli(function (argv) {
argv.config = 'nightwatch.conf.js';
argv.source= 'folder of tests i want to run';
const runner = Nightwatch.CliRunner(argv);
runner
.setup()
.startWebDriver()
.then(() => {
return runner.runTests()
})
.then(() => {
return runner.stopWebDriver()
})
.catch(err => console.error(err));
});
})
As you know, the config file is exported as an object. If you are able to read the file contents and store it into a variable, you can try to override the property src_folders
.
const red = require('../nightwatch.conf');
console.log(red.src_folders)