Reputation: 1967
I have end to end tests written using jasmine and behavioural driven tests written using chai and cucumber. I have two configurations file to run these tests. How can I make use of single protractor config file to run specs of jasmine and cucumber ?
//cucumber.conf.js
exports.config = {
framework: 'custom',
frameworkPath: require.resolve('protractor-cucumber-framework'),
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['test/e2e/cucumber/*.feature'],
capabilities: {
'browserName': 'firefox',
},
baseUrl: '',
cucumberOpts: {
require: ['test/e2e/cucumber/*.steps.js'],
tags: [],
strict: true,
format: ["pretty"],
dryRun: false,
compiler: []
}
//e2e.conf.js
exports.config = {
framework: 'jasmine2',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['test/e2e/e2e-spec.js'],
capabilities: {
'browserName': 'firefox',
},
baseUrl: '',
jasmineNodeOpts: {
showColors: true,
}
Upvotes: 0
Views: 1012
Reputation: 2375
In a basic setup you can't because you need to provide for example the framework and you can't have 2 frameworks in 1 default configuration file.
What you can do is use a command line argument and a cli tool like yargs and do something like this. If you run protractor through for example a npm script
you can do something like this
npm run e2e -- --bdd
// the commmand line tool
const argv = require('yargs').argv;
// place you default config here, that should hold all the configs that are used with
// Jsasmine and CucumberJS
const config = {
baseUrl: '',
capabilities: {
'browserName': 'firefox',
},
seleniumAddress: 'http://localhost:4444/wd/hub'
};
// If you pass --bdd to your commandline it will use cucumberjs, default is jasmine 2
if (argv.bdd) {
config.framework = 'custom';
config.frameworkPath = require.resolve('protractor-cucumber-framework');
config.specs = ['test/e2e/cucumber/*.feature'];
config.cucumberOpts = {
require: ['test/e2e/cucumber/*.steps.js'],
tags: [],
strict: true,
format: ["pretty"],
dryRun: false,
compiler: []
};
} else {
config.framework = 'jasmine2';
config.specs = ['test/e2e/e2e-spec.js'];
config.jasmineNodeOpts = {
showColors: true,
};
}
exports.config = config;
Upvotes: 1