protractor-cucumber-framework
Advanced tools
Comparing version 0.1.3 to 0.2.0
103
index.js
var q = require('q'), | ||
glob = require('glob'), | ||
assign = require('object-assign'), | ||
path = require('path'); | ||
@@ -15,92 +15,25 @@ | ||
var Cucumber = require('cucumber'), | ||
execOptions = ['node', 'node_modules/.bin/cucumber-js'], | ||
cucumberResolvedRequire; | ||
// Set up exec options for Cucumber | ||
execOptions = execOptions.concat(specs); | ||
if (runner.getConfig().cucumberOpts) { | ||
var execOptions = assign({ | ||
format: [], | ||
tags: [], | ||
require: [], | ||
compiler: [] | ||
}, runner.getConfig().cucumberOpts); | ||
var configDir = runner.getConfig().configDir; | ||
// Process Cucumber Require param | ||
if (runner.getConfig().cucumberOpts.require) { | ||
// TODO - this should move into the launcher. | ||
var requirePatterns = runner.getConfig().cucumberOpts.require; | ||
var configDir = runner.getConfig().configDir; | ||
requirePatterns = (typeof requirePatterns === 'string') ? | ||
[requirePatterns] : requirePatterns; | ||
cucumberResolvedRequire = []; | ||
if (requirePatterns) { | ||
for (var i = 0; i < requirePatterns.length; ++i) { | ||
// Cucumber allows running a spec given a line number. | ||
// If you deprecated node < v0.12, switch to using path.parse | ||
var fileName = requirePatterns[i]; | ||
var lineNumber = /:\d+$/.exec(fileName); | ||
if (lineNumber) { | ||
fileName = fileName.slice(0, lineNumber.index); | ||
lineNumber = lineNumber[0].slice(1); | ||
} | ||
var matches = glob.sync(fileName, {cwd: configDir}); | ||
if (!matches.length) { | ||
log.warn('pattern ' + requirePatterns[i] + ' did not match any files.'); | ||
} | ||
for (var j = 0; j < matches.length; ++j) { | ||
var resolvedPath = path.resolve(configDir, matches[j]); | ||
if (lineNumber) { | ||
resolvedPath += ':' + lineNumber; | ||
} | ||
cucumberResolvedRequire.push(resolvedPath); | ||
} | ||
} | ||
} | ||
if (cucumberResolvedRequire && cucumberResolvedRequire.length) { | ||
execOptions = cucumberResolvedRequire.reduce(function(a, fn) { | ||
return a.concat('-r', fn); | ||
}, execOptions); | ||
} | ||
// Make sure that some option are array | ||
['compiler', 'format', 'tags', 'require'].forEach(function (option) { | ||
if (!Array.isArray(execOptions[option])) { | ||
execOptions[option] = [ execOptions[option] ]; | ||
} | ||
}); | ||
// Process Cucumber Tag param | ||
if (Array.isArray(runner.getConfig().cucumberOpts.tags)) { | ||
for (var i in runner.getConfig().cucumberOpts.tags) { | ||
var tags = runner.getConfig().cucumberOpts.tags[i]; | ||
execOptions.push('-t'); | ||
execOptions.push(tags); | ||
} | ||
} else if (runner.getConfig().cucumberOpts.tags) { | ||
execOptions.push('-t'); | ||
execOptions.push(runner.getConfig().cucumberOpts.tags); | ||
} | ||
// Resolve require absolute path | ||
execOptions.require = execOptions.require.map(function (requirePath) { | ||
return path.resolve(configDir, requirePath) | ||
}) | ||
// Process Cucumber Format param | ||
if (Array.isArray(runner.getConfig().cucumberOpts.format)) { | ||
runner.getConfig().cucumberOpts.format.forEach(function (format) { | ||
execOptions.push('-f'); | ||
execOptions.push(format); | ||
}); | ||
} else if (runner.getConfig().cucumberOpts.format) { | ||
execOptions.push('-f'); | ||
execOptions.push(runner.getConfig().cucumberOpts.format); | ||
} | ||
// Process Cucumber 'coffee' param | ||
if (runner.getConfig().cucumberOpts.coffee) { | ||
execOptions.push('--coffee'); | ||
} | ||
// Process Cucumber 'no-snippets' param | ||
if (runner.getConfig().cucumberOpts.noSnippets) { | ||
execOptions.push('--no-snippets'); | ||
} | ||
// Process Cucumber 'dry-run' param | ||
if (runner.getConfig().cucumberOpts.dryRun) { | ||
execOptions.push('-d'); | ||
} | ||
} | ||
global.cucumber = Cucumber.Cli(execOptions); | ||
@@ -197,3 +130,3 @@ | ||
return q.promise(function(resolve, reject) { | ||
var cucumberConf = Cucumber.Cli.Configuration(execOptions); | ||
var cucumberConf = Cucumber.Cli.Configuration(execOptions, specs); | ||
var runtime = Cucumber.Runtime(cucumberConf); | ||
@@ -200,0 +133,0 @@ var formatters = cucumberConf.getFormatter ? |
{ | ||
"name": "protractor-cucumber-framework", | ||
"version": "0.1.3", | ||
"version": "0.2.0", | ||
"description": "Protractor framework for Cucumber.js", | ||
@@ -35,7 +35,7 @@ "main": "index.js", | ||
"dependencies": { | ||
"glob": "^6.0.1", | ||
"object-assign": "^4.0.1", | ||
"q": "^1.4.1" | ||
}, | ||
"peerDependencies": { | ||
"cucumber": ">= 0.5 <= 0.8.1" | ||
"cucumber": "^0.9.1" | ||
}, | ||
@@ -45,3 +45,3 @@ "devDependencies": { | ||
"chai-as-promised": "^5.1.0", | ||
"cucumber": "^0.8.1", | ||
"cucumber": "^0.9.1", | ||
"httpster": "^1.0.1", | ||
@@ -48,0 +48,0 @@ "protractor": "^2.5.1" |
Protractor Cucumber Framework | ||
============================= | ||
[![Build Status](https://travis-ci.org/mattfritz/protractor-cucumber-framework.svg?branch=master)](https://travis-ci.org/mattfritz/protractor-cucumber-framework) | ||
This framework was originally part of [angular/protractor](https://github.com/angular/protractor) and | ||
@@ -18,4 +20,2 @@ is now a separate module to decouple [cucumber.js](https://github.com/cucumber/cucumber-js). | ||
```js | ||
var cucumberFrameworkPath = require('protractor-cucumber-framework').resolve(); | ||
exports.config = { | ||
@@ -26,4 +26,4 @@ // set to "custom" instead of cucumber. | ||
// path relative to the current config file | ||
frameworkPath: cucumberFrameworkPath | ||
frameworkPath: 'protractor-cucumber-framework' | ||
}; | ||
``` |
8231
138
+ Addedobject-assign@^4.0.1
+ Addedcallsite@1.0.0(transitive)
+ Addedcamel-case@1.2.2(transitive)
+ Addedcli-table@0.3.11(transitive)
+ Addedcolors@1.0.31.4.0(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addedcucumber@0.9.5(transitive)
+ Addedcucumber-html@0.2.4(transitive)
+ Addedfs.realpath@1.0.0(transitive)
+ Addedglob@7.2.3(transitive)
+ Addedlodash@4.17.21(transitive)
+ Addedlower-case@1.1.4(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedsentence-case@1.1.3(transitive)
+ Addedstack-chain@1.3.7(transitive)
+ Addedupper-case@1.1.3(transitive)
- Removedglob@^6.0.1
- Removedabbrev@1.1.1(transitive)
- Removedcolors@1.1.2(transitive)
- Removedcucumber@0.8.1(transitive)
- Removedcucumber-html@0.2.3(transitive)
- Removedglob@6.0.4(transitive)
- Removednopt@3.0.4(transitive)
- Removedstack-chain@1.3.3(transitive)
- Removedunderscore@1.8.3(transitive)
- Removedunderscore.string@3.2.2(transitive)
- Removedwalkdir@0.0.10(transitive)