vgamula / gulp-cucumber Goto Github PK
View Code? Open in Web Editor NEWGulp task for running cucumber.js features
License: MIT License
Gulp task for running cucumber.js features
License: MIT License
Hello,
after cucumber version was updated i run into an issue:
cucumber event handlers attached via registerHandler are now passed the associated object instead of an event
getPayloadItem will be removed in the next major release
C:\dev\Topic Analyst\Frontend\node_modules\cucumber\lib\cucumber\runtime\event_broadcaster.js:30
throw error;
^
function accepts a callback and returns a promise
0 passing (3.30s)
[10:43:31] 'cucumber' errored after 3.51 s
[10:43:31] Error in plugin 'gulp-webdriver'
Message:
wdio exited with code 1
I got an answer from cucumber: cucumber/cucumber-js#601 (comment)
we are hooking to "beforeFeature" - I think gulp-cucumber uses callbacks. If so cna you do cucumber version upgrade and made a fix for this?
If you are using semver as a tag in git it is easy to install the node module direct out of git in your project
Currently we have to use the gulp-exit plugin to get gulp-cucumber to exit when the tests are done:
var gulp = require('gulp'),
plugins = require('gulp-load-plugins')();
gulp.task('cucumber', ['env-test'], function () {
return gulp.src('features/*')
.pipe(plugins.cucumber({
'steps': 'features/**/*.steps.js',
'support': 'features/support/*.js',
'format': 'pretty',
'tags': '~@ignore'
}))
.pipe(plugins.exit());
});
Perhaps for this reason we also do not get exit code 1 when cucumber tests fail. How are others using this plugin?
(Tried both 0.0.14 and 0.0.22)
Do I need to set the options.support to the location of where I define world.js so that I can use the world abstraction wherever I need to? If I don't do so, I get an error when I run my tests such as field not defined
.
Is it possible to use the Babel transpiler for ES6 code in gulp mocha its possible by passing flag:
compilers: {
js: babel
}
/**
* Run Unit tests
*/
gulp.task('test:unit', 'Launch Unit Test Runner - Mocha', function () {
return gulp.src(['test/**/*.test.js'])
.pipe($.mocha({
compilers: {
js: babel
},
timeout: 1500,
reporter: 'min'
}));
});
/**
* Run BDD tests
*/
gulp.task('test:bdd', 'Launch BDD Test Runner - Cucumber', function (callback) {
return gulp.src('test/features/**/*.feature').pipe($.cucumber({
'steps': 'test/features/**/step_definitions/*.steps.js',
'support': 'test/features/**/support/*.js',
})).once('end', function () {
console.log('stream end!!');
callback();
});
});
Would it be possible to add support for world-parameters?
Thanks
This is my gulpfile:
var gulp = require('gulp');
var cucumber = require('gulp-cucumber')
var browserStack = require('gulp-browserstack');
gulp.task('cucumber', function() {
return gulp.src('features/my_feature.feature')
.pipe(browserStack.startTunnel({
key: '<itsasecret>'
}))
.pipe(cucumber({}))
.pipe(browserStack.stopTunnel());
});
When all the scenarios pass, gulp hangs, and never exits.
Is there a way to use Cucumberjs's ability to write the outputs of a test to a specific directory within the gulpfile?
See travis-ci build output here: https://travis-ci.org/joniba/bidding-express-test/jobs/88510330
Source code here: https://github.com/joniba/bidding-express-test
Could it have to do with my BeforeFeatures and AfterFeatures hooks (https://github.com/joniba/bidding-express-test/blob/master/features/support/hooks.js)? I'm trying to start the server before running the BDD tests and shut down the server once they are done. I'm calling process.exit because otherwise running cucumber via gulp-cucumber does not exit.
For comparison, the same concept is working when using mocha: https://travis-ci.org/joniba/bidding-express-test/jobs/88523877 (5 tests failed and gulp-mocha exits with code 1, not 0, causing the build to fail).
Hello,
Do you have any suggestions for piping the results to file?
Cucumber build not exiting with 1 on failure. The pull request #29 fixes this. Can it be merged in please.
Please publish this to npm
Is there a way to use Cucumberjs's ability to write the outputs of a test to a specific directory within the gulpfile?
It seems that there is a difference between the current repository and what is published in npm. But both versions are 0.0.4
.
Plugin version might be updated as well as npm repository
Just an FYI for anyone who is experiencing hangs in their build after upgrading to gulp-connect
v0.0.19
The change in PR #29 was a breaking change. We had some logic that was listening for the 'end'
event and was then shutting down our test servers.
Its fixable by changing your logic from something like:
gulp.task('test:client:integration', function (callback) {
var options = { ... };
gulp
.src(paths.clients.features)
.pipe($.cucumber(options)).on('end', function () {
testServer.shutdown(callback)
});
});
to:
gulp.task('test:client:integration', ['test:client:cucumber'], function (callback) {
testServer.shutdown(callback);
});
gulp.task('test:client:cucumber', function () {
var options = { ... };
return gulp
.src(paths.clients.features)
.pipe($.cucumber(options));
});
Cucumber cli returns following object when
{ shouldExitImmediately: false, success: true }
Due to this update condition is always evaluated to true and does not thorw errors when test fails
cli.run().then((success) => {
if (success || !emitErrors) {
I have checked difference between versions and this change was introduced in version 4 of cucumber and it was not working properly since.
I followed your README and perhaps found a typo?
For me, this as shown in the README, didn't work:
gulp.task('cucumber', function() {
return gulp.src('./test/server/features/foo/*.feature').pipe(cucumber({
"steps": './test/server/features/definitions/*.js',
"support": './test/server/features/support/*.js'
}));
});
but this, without the quoted keys, did work:
gulp.task('cucumber', function() {
return gulp.src('./test/server/features/foo/*.feature').pipe(cucumber({
steps: './test/server/features/definitions/*.js',
support: './test/server/features/support/*.js'
}));
});
Any ideas?
I'm on OSX 10.10.5, Node v4.3.2, Gulp CLI version 1.1.0, Gulp local version 3.9.1
I would like to test my project with cucumber.js, but with Typescript files. This can be achieved by the following command line:
cucumber-js --require-module ts-node/register --require "steps/**/*.ts"
The gulp plugin still uses the older --compiler ts:ts-node/register
parameter. It would be very helpful if the plugin would facilitate for the newer command line options of cucumber 4.x
Since this npm library was developed with old version of Cucumber npm dependency, it is not possible to upgrade the cucumber version since the old library is deprecated and the new library's location has changed.
Need to update the Gulp-Cucumber library with the new Cucumber library which is @cucumber/cucumber and not not cucumber only
I've been receiving an ENOENT error trying to run gulp-cucumber, even though I have no problems executing the same cucumber-js command from the command line, so I had to look into it some more and I found that this line:
var UnixPath = __dirname + '/node_modules/cucumber/bin/cucumber.js';
was actually binding the path relative to the gulp-cucumber directory:
'~/appName/node_module/gulp-cucumber/node_modules/cucumber/bin/cucumber.js'
instead of
'~/appName/node_modules/cucumber/bin/cucumber.js'
Changing the path prefix to process.cwd()
fixed it.
var UnixPath = process.cwd() + '/node_modules/cucumber/bin/cucumber.js';
I am running:
• Mac OSX 10.10
• gulp CLI v3.6.1
• gulp Local v3.8.9
Current cucumber is 0.9.2
, can this project be upgraded to use that version ?
a little autoexecutable test with a .travis.yml file for CI would be nicey
If I use gulp-cucumber in connection with some sort of watch (e.g. gulp.watch or gulp-watch), cucumber doesn't reload the step files when i kick off the new cucumber execution. Internally, cucumber.js is using require() to load the step files, so they are already cached when gulp-cucumber executes the CLI a second time.
Hi 😄,
My gulp task looks like below:
gulp.task('test:acceptance', function() {
return gulp.src('test/*').pipe(cucumber({
'steps': 'test/functional/*.js',
'support': 'test/functional/support/*.js',
}));
});
But I keep getting the below error:
fs.js:1574
return binding.realpath(pathModule._makeLong(path), options.encoding);
^
Error: ENOENT: no such file or directory, realpath 'features'
at Error (native)
at Object.realpathSync (fs.js:1574:18)
at Object.expandPathWithExtensions (/Users/Marthinus/Code/global-web/sbg-module-generator/node_modules/gulp-cucumber/node_modules/cucumber/lib/cucumber/cli/path_expander.js:15:23)
at /Users/Marthinus/Code/global-web/sbg-module-generator/node_modules/gulp-cucumber/node_modules/cucumber/lib/cucumber/cli/path_expander.js:9:27
at Array.map (native)
at Object.expandPathsWithExtensions (/Users/Marthinus/Code/global-web/sbg-module-generator/node_modules/gulp-cucumber/node_modules/cucumber/lib/cucumber/cli/path_expander.js:7:31)
at Object.expandPaths (/Users/Marthinus/Code/global-web/sbg-module-generator/node_modules/gulp-cucumber/node_modules/cucumber/lib/cucumber/cli/feature_path_expander.js:9:38)
at Function.Configuration (/Users/Marthinus/Code/global-web/sbg-module-generator/node_modules/gulp-cucumber/node_modules/cucumber/lib/cucumber/cli/configuration.js:21:63)
at getConfiguration (/Users/Marthinus/Code/global-web/sbg-module-generator/node_modules/gulp-cucumber/node_modules/cucumber/lib/cucumber/cli.js:63:38)
at Object.run (/Users/Marthinus/Code/global-web/sbg-module-generator/node_modules/gulp-cucumber/node_modules/cucumber/lib/cucumber/cli.js:69:27)
My modules folder structure is:
root
| ----- test
|-----functional
|---folder_with_tests
|---another_folder_with_tests
|---support
Hi there,
I am using cucumber-js 3 and having problems running cucumber tests with gulp-cucumber. Same feature files are working with cucumber-js but failing with gulp-cucumber.
Here is the error I am getting:
[21:29:02] Starting 'cucumber'...
path.js:28
throw new TypeError('Path must be a string. Received ' + inspect(path));
^
TypeError: Path must be a string. Received undefined
at assertPath (path.js:28:11)
at Object.relative (path.js:1254:5)
at getDefinitionLineAndUri (/Users/ooo/projects/poc/gulp-cucumber-test/node_modules/cucumber/lib/support_code_library_builder/define_helpers.js:144:28)
at /Users/ooo/projects/poc/gulp-cucumber-test/node_modules/cucumber/lib/support_code_library_builder/define_helpers.js:108:34
at /Users/ooo/projects/poc/gulp-cucumber-test/features/step_definitions/browser_steps.js:5:3
at defineSupportCode (/Users/ooo/projects/poc/gulp-cucumber-test/node_modules/cucumber/lib/support_code_library_builder/index.js:43:9)
at Object.<anonymous> (/Users/ooo/projects/poc/gulp-cucumber-test/features/step_definitions/browser_steps.js:4:1)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
at /Users/ooo/projects/poc/gulp-cucumber-test/node_modules/gulp-cucumber/node_modules/cucumber/lib/cucumber/cli/support_code_loader.js:63:29
at Array.forEach (<anonymous>)
Any ideas or workarounds?
Cheers
[14:29:52] Using gulpfile \gulpfile.js
[14:29:52] Starting 'unit-test'...
[14:29:52] Finished 'unit-test' after 22 ms
Feature: a
....
I think the gulp task should end after the cucumber tests.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.