protractor-cucumber-framework
Advanced tools
Comparing version 1.0.0 to 1.0.1
66
index.js
@@ -1,8 +0,7 @@ | ||
var q = require('q'), | ||
path = require('path'), | ||
glob = require('glob'), | ||
assign = require('object-assign'), | ||
debug = require('debug')('protractor-cucumber-framework'), | ||
Cucumber = require('./lib/cucumberLoader').load(), | ||
state = require('./lib/runState'); | ||
let q = require('q'); | ||
let path = require('path'); | ||
let glob = require('glob'); | ||
let debug = require('debug')('protractor-cucumber-framework'); | ||
let Cucumber = require('./lib/cucumberLoader').load(); | ||
let state = require('./lib/runState'); | ||
@@ -17,11 +16,11 @@ /** | ||
exports.run = function(runner, specs) { | ||
var results = {}; | ||
let results = {}; | ||
return runner.runTestPreparer().then(function() { | ||
var config = runner.getConfig(); | ||
var opts = assign({}, config.cucumberOpts, config.capabilities.cucumberOpts); | ||
let config = runner.getConfig(); | ||
let opts = Object.assign({}, config.cucumberOpts, config.capabilities.cucumberOpts); | ||
state.initialize(runner, results, opts.strict); | ||
return q.promise(function(resolve, reject) { | ||
var cliArguments = convertOptionsToCliArguments(opts); | ||
let cliArguments = convertOptionsToCliArguments(opts); | ||
cliArguments.push('--require', path.resolve(__dirname, 'lib', 'resultsCapturer.js')); | ||
@@ -38,5 +37,5 @@ cliArguments = cliArguments.concat(specs); | ||
function runDone(isSuccessful) { | ||
function runDone() { | ||
try { | ||
var complete = q(); | ||
let complete = q(); | ||
if (runner.getConfig().onComplete) { | ||
@@ -60,11 +59,9 @@ complete = q(runner.getConfig().onComplete()); | ||
function convertOptionsToCliArguments(options) { | ||
var cliArguments = ['node', 'cucumberjs']; | ||
let cliArguments = ['node', 'cucumberjs']; | ||
for (var option in options) { | ||
var cliArgumentValues = convertOptionValueToCliValues(option, options[option]); | ||
for (let option in options) { | ||
let cliArgumentValues = convertOptionValueToCliValues(option, options[option]); | ||
if (Array.isArray(cliArgumentValues)) { | ||
cliArgumentValues.forEach(function (value) { | ||
cliArguments.push('--' + option, value); | ||
}); | ||
cliArgumentValues.forEach((value) => cliArguments.push('--' + option, value)); | ||
} else if (cliArgumentValues) { | ||
@@ -79,23 +76,16 @@ cliArguments.push('--' + option); | ||
function convertRequireOptionValuesToCliValues(values) { | ||
var configDir = runner.getConfig().configDir; | ||
let configDir = runner.getConfig().configDir; | ||
return toArray(values).map(function(path) { | ||
// Handle glob matching | ||
return glob.sync(path, {cwd: configDir}); | ||
}).reduce(function(opts, globPaths) { | ||
// Combine paths into flattened array | ||
return opts.concat(globPaths); | ||
}, []).map(function(requirePath) { | ||
// Resolve require absolute path | ||
return path.resolve(configDir, requirePath); | ||
}).filter(function(item, pos, orig) { | ||
// Make sure requires are unique | ||
return orig.indexOf(item) == pos; | ||
}); | ||
return toArray(values) | ||
.map((path) => glob.sync(path, {cwd: configDir})) // Handle glob matching | ||
.reduce((opts, globPaths) => opts.concat(globPaths), []) // Combine paths into flattened array | ||
.map((requirePath) => path.resolve(configDir, requirePath)) // Resolve require absolute path | ||
.filter((item, pos, orig) => orig.indexOf(item) == pos); // Make sure requires are unique | ||
} | ||
function convertTagsToCliValues(values) { | ||
var converted = toArray(values).map(function(tag) { | ||
return tag.replace(/~/, 'not '); | ||
}).join(' and '); | ||
function convertTagsToV2CliValues(values) { | ||
let converted = toArray(values) | ||
.filter((tag) => !!tag.replace) | ||
.map((tag) => tag.replace(/~/, 'not ')) | ||
.join(' and '); | ||
@@ -117,3 +107,3 @@ return [converted]; | ||
} else if (option === 'tags' && isCucumber2()) { | ||
return convertTagsToCliValues(values) | ||
return convertTagsToV2CliValues(values); | ||
} else { | ||
@@ -120,0 +110,0 @@ return convertGenericOptionValuesToCliValues(values); |
module.exports.load = function() { | ||
if (process.env.MULTIDEP_CUCUMBER_VERSION) { | ||
return require('multidep')('spec/multidep.js')('cucumber', process.env.MULTIDEP_CUCUMBER_VERSION); | ||
return require('multidep')('test/multidep.js')('cucumber', process.env.MULTIDEP_CUCUMBER_VERSION); | ||
} else { | ||
return require('cucumber'); | ||
} | ||
} | ||
}; |
@@ -61,3 +61,3 @@ var state = require('./runState'); | ||
passed: false, | ||
errorMsg: "Undefined steps are not allowed in strict mode" | ||
errorMsg: 'Undefined steps are not allowed in strict mode' | ||
}); | ||
@@ -78,3 +78,3 @@ } | ||
duration: 0 | ||
} | ||
}; | ||
} | ||
@@ -91,2 +91,1 @@ | ||
} | ||
{ | ||
"name": "protractor-cucumber-framework", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Protractor framework for Cucumber.js", | ||
@@ -11,5 +11,6 @@ "main": "index.js", | ||
"webdriver": "webdriver-manager update --standalone && webdriver-manager start", | ||
"start": "httpster -d testapp/ -p `node -p 'process.env.HTTP_PORT || require(\"./spec/environment\").webServerDefaultPort'`", | ||
"pretest": "multidep spec/multidep.js", | ||
"test": "node scripts/test.js" | ||
"start": "node test/testapp/server", | ||
"lint": "eslint .", | ||
"pretest": "npm run lint && multidep test/multidep.js", | ||
"test": "node test/test.js" | ||
}, | ||
@@ -57,2 +58,4 @@ "repository": { | ||
"chai-as-promised": "6.0.0", | ||
"eslint": "3.16.1", | ||
"express": "4.14.1", | ||
"httpster": "1.0.3", | ||
@@ -59,0 +62,0 @@ "multidep": "2.0.2", |
@@ -29,8 +29,9 @@ Protractor Cucumber Framework | ||
specs: [ | ||
'path/to/feature/files/**/*.feature' // accepts a glob | ||
], | ||
'path/to/feature/files/**/*.feature' // accepts a glob | ||
], | ||
cucumberOpts: { | ||
// require step definitions | ||
// require step definitions | ||
require: [ | ||
'path/to/step/definitions/**/*.steps.js' // accepts a glob | ||
'path/to/step/definitions/**/*.steps.js' // accepts a glob | ||
] | ||
@@ -58,8 +59,8 @@ } | ||
Start up the test app that tests will be run against: | ||
Start up the test app that tests will be run against in a separate shell: | ||
npm start | ||
Run the tests: | ||
Run the tests in a separate shell: | ||
npm test |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
65
0
11047
7
9
185