Reputation: 764
I am stuck with Gulp as a wrapper. I have multiple spec files in my work for different projects(websites) and i want to create test suites out of these spec files. Below is the code written by someone in gulp `
var binPath = './node_modules/.bin/';
gulp.task('test-all', function(cb) {
async.eachSeries(glob.sync('sites/*'), testSite, cb);
});
gulp.task('test', function(cb) {
env.validate(util.env, {
site: {
required: true,
},
useSelenium: {
required: false,
},
params: {
required: false,
}
});
testSite('sites/' + util.env.site, cb);
});
gulp.task('explorer', function(cb) {
runProtractor(['--elementExplorer', '--directConnect'], cb);
});
gulp.task('serve', function(cb) {
runModule('webdriver-manager', ['start'], cb);
});
gulp.task('update', function(cb) {
runModule('webdriver-manager', ['update'], cb);
});
gulp.task('default', ['test']);
function runModule(name, params, cb) {
new simpleCommand(path.join(binPath, name), params, process.cwd()).run(cb);
}
function runProtractor(params, cb) {
runModule('protractor', params, cb);
}
function testSite(site, cb) {
var params = [
site + '/protractor.conf.js', suite=smoke,
'--params.timestamp=' + timestamp
];
if (!util.env.useSelenium) {
params.push('--directConnect');
}
if (util.env.params) {
params.push(util.env.params.replace(/(^['"]|['"]$)/g, '').trim());
}
util.log('Testing ' + site);
runProtractor(params, function(err) {
if (err) {
util.log(err);
}
cb();
});
}
` I have now specified suite name which i want to execute above. But i want to capture this name of suite from command line argument.
gulp test --site [sitename] --suite=smoke
How will i be able to capture suite name from above statement?
Upvotes: 0
Views: 161
Reputation: 764
I got this to work.
function testSite(site, cb) {
var params = [
site + '/protractor.conf.js', '--suite='+util.env.suite,
'--params.timestamp=' + timestamp
Upvotes: 0