Reputation: 357
I'm trying to create grunt tasks using grunt-protractor-runner with my protractor-cucumber framework. Below is how the Gruntfile.js looks like:
grunt.initConfig({
protractor: {
options: {
//configFile: "./config/config.js",
keepAlive: true,
noColor: false,
},
chrome: {
options: {
configFile: "./config/config.js",
args: {
autoConnect: false,
seleniumServerJar: './node_modules/webdriver-manager/selenium/selenium-server-standalone-3.141.59.jar',
chromeDriver: './node_modules/webdriver-manager/selenium/chromedriver.exe',
specs: [
'../features/calendar.feature',
'../features/deal.feature',
'../features/entitlement.feature',
'../features/filter.feature',
'../features/product.feature'
],
capabilities: {
browserName: 'chrome',
chromeOptions: {
useAutomationExtension: false,
args: ['–disable-gpu'],
}
}
}
}
}
},
});
grunt.registerTask('test', ['protractor:chrome']);
If I run command grunt test it opens the chrome browser and closes with the below log:
Running "protractor:chrome" (protractor) task [17:22:57] I/launcher - Running 1 instances of WebDriver [17:22:57] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
0 scenarios 0 steps 0m00.000s
This doesn't pick any scenarios to run. Can you help me to understand what's the issue here? My config.conf looks like this:
const Reporter = require('../support/Reporter.js');
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
autoConnect: false,
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
restartBrowserBetweenTests: false,
SELENIUM_PROMISE_MANAGER: true,
ignoreUncaughtExceptions: true,
onPrepare: function () {
browser.ignoreSynchronization = false;
browser.manage().timeouts().setScriptTimeout(40 * 1000);
browser.manage().timeouts().implicitlyWait(4 * 1000);
browser.manage().window().maximize();
require('babel-register');
},
cucumberOpts: {
strict: true,
format: ['json:./reports/json/cucumber_report.json'],
require: ['../support/*.js', '../stepDefinitions/*.js', '../stepDefinitions/*.ts'],
tags: 'not @Ignore', //(@CucumberScenario or @ProtractorScenario) and (not @Ignore)
retry: 3
},
params: {
env: 'test',
test: {
url: '',
users: {
BankerRO: '',
BankerRW: '',
BusinessRiskRW: '',
RiskRW: '',
RO: '',
},
db: {
server: '',
port: '',
name: '',
userId: '',
password: '',
}
}
},
onComplete: function () {
Reporter.moveReportToArchive();
Reporter.createHTMLReport();
}
};
Upvotes: 0
Views: 110
Reputation: 357
I finally found out the root-cause, if I keep spec[] part in the Gruntfile, grunt fails to pick the scenarios even from config.js. When I removed spec from Gruntfile and kept it in the config.js, it started working fine. I'm not sure this is how it works or a potential bug with grunt-protractor-runner
Conclusion: Looks like grunt-protractor-runner looks for specs in config.js file and ignores if you keep it in Gruntfile.js
I have raised this as an issue: https://github.com/teerapap/grunt-protractor-runner/issues/197#issue-537600108
Upvotes: 0