cucumber / cucumber-js Goto Github PK
View Code? Open in Web Editor NEWCucumber for JavaScript
Home Page: https://cucumber.io
License: MIT License
Cucumber for JavaScript
Home Page: https://cucumber.io
License: MIT License
Add support for scenario outlines and examples.
Missing step definitions trigger ugly "Cannot call method 'invoke' of undefined" exceptions. Fix that!
See #49
2011-05-30 #cucumber:
11:59 <aslakhellesoy> jbpros: one thing that would be useful in cucumber.js is an API call to get all of the stepdefs
12:00 <aslakhellesoy> following this spec: https://github.com/cucumber/gherkin/wiki/Code-Completion
12:00 <aslakhellesoy> (see the json doc at the bottom for a quick example)
12:00 <aslakhellesoy> if cucumber.js provides those we can feed them to gherkin-editor
I'd like to run cucumber.js and node (with nodemon) in a manner similar to guard and cucumber_rails. That would mean you'd need some kind of autorun option like jasmin-node does.
Is that a feature on the horizon?
Throw an error when no actual world instance is passed back by the constructor.
Add support for step arguments transforms.
https://github.com/cucumber/cucumber/wiki/Step-Argument-Transforms
Only execute parts of a feature.
Some existing step definitions depend on this (e.g. When(/^Cucumber executes the scenario "([^"]*)"$/, ...);
). Update them as soon as this is finished.
Missing step definitions are currently marked as "U" (undefined) by the progress formatter without any other kind of information. The user should be told which step (i.e. its name) needs it.
What about the step definition snippet suggestion? I guess many users like those.
Good day
I tried to set the test up with Windows, but it is not working. It works with Mac OS and with Linux.
My node version is 0.6.10
The test is:
Feature: Test
It throws an error when I run the test. The error is: ReferenceError: Test is not defined.
Do you maybe have any suggestions what could be wrong?
Regards,
Channel
Checking out cucumber-js from Github or installing it as a Node module, the example HTML file doesn't work as it is missing browserify and whatever file structure of Node modules it requires.
Some documentation on how to get the example working would be greatly appreciated.
Hi,
I'm running the tests in cucumber-js like this (full steps to eliminate ambiguity):
$ git clone https://github.com/cucumber/cucumber-js.git
$ cd cucumber-js
$ npm install # using --dev fails on browserify. some version problem with connect.
$ sudo npm link
$ node_modules/.bin/jasmin-node spec
894 tests, 1175 assertions, 304 failures
My question is, is there something wrong with my environment, or are these failures expected at the moment?
Use the "progress" formatter (listener) in cucumber feature suite step definitions.
Allow calling steps from step definitions.
https://github.com/cucumber/cucumber/wiki/Calling-Steps-from-Step-Definitions
Asynchronous exceptions are currently not caught: they interrupt Cucumber execution, print out the stack trace and end the process altogether.
It's possible to catch asynchronous exceptions on both Node.js and browsers through process.on('uncaughtException', ...)
and window.onerror
, respectively.
The catching function should call the current step callback.fail()
function and pass it the caught exception so that Cucumber can report the failing step and proceed with the next scenario, if any.
Interesting Fact™: this will be the first piece of code in Cucumber.js that needs branching depending on wether it's running on Node or a browser.
I would like to be able to do something like this:
node cucumber.js features
This will load a web page and all the javascript that it depends on (defined in support/env.js?).
It will then execute all of the features against that loaded web page.
This is the sort of workflow I expected to be able to accomplish with node, but I can't see how to do it.
Any help?
Mike
Failing steps abruptly halt the execution of the current feature by throwing an exception. Failures should be caught and following steps within the scenario should be skipped. Next scenarios and features should be executed.
I don't know yet if the result of the whole process (success/failure) should be returned to the callback passed to Cucumber.start() or if that responsibility should be left to listeners...
have followed the guidance, installed nodejs via msi. file
after that npm install would work only under c:\programfiles \nodejs. and everytime copied my whole workshop folder structure under node.js.
i tried both local and global npm run. after restrating machine i was able to run npm install to run under my workshop as workshopfolder\npm install --dev
it went smooth with instaling
however when i type @node_env=test .. as in guidance. it keep saying that it s not recognized command
however when i type cucumber.js it gives me script error pop up.
saying :
Script:
c.:\ users.currentuser\appdata\roaming\npm\cucumber.js
line:1
char:1
error:invalid character
code:800a03f6
source: miscrosoft jscript compilation error
when i open c.:\ users.currentuser\appdata\roaming\npm\cucumber.js i am having this
if [ -x "dirname "$0"
/node" ]; then
"dirname "$0"
/node" "dirname "$0"
/../cucumber/bin/cucumber.js" "$@"
ret=$?
else
node "dirname "$0"
/../cucumber/bin/cucumber.js" "$@"
ret=$?
fi
exit $ret
thanks for prompt response #jbpros
I am trying to use cucumber.js to test an express.js web application.
The test scenarios are creating new objects in MongoDb database,
and I need to clear it before running the tests.
Mongodb operations are asynchronous, so if I clear the database
from world constructor, then I have a race condition with test execution.
I came up with an idea how asynchronous initialization can be supported,
please see the fork at git://github.com/salikh/cucumber-js.git.
To request asynchronous initialization, the feature writer needs
to inherit from the EventEmitter by writing the following line:
this.__proto__ = new process.EventEmitter
Then the world constructor can indicate that it finished initialization
by firing an event on itself:
world.emit('init done')
The world initializer tests if the asynchronous initialization is
required by the following condition:
if (world.__proto__.constructor == process.EventEmitter)
and if the condition matches, it starts test execution asynchronously:
world.on('init done', function() {
cont()
})
Add support for scenario (#31), step, tagged and global hooks.
Add support for data tables.
https://github.com/cucumber/cucumber/wiki/multiline-step-arguments
Add support for "Background" elements.
In order to display the full power of cucumber.js and gherkin-editor combined together, these two should be used on example/index.html.
Allow comments in features.
Should comments be considered "basic feature elements" (i.e. vital to run the cucumber-features suite)? https://github.com/cucumber/cucumber-features/blob/master/basic_feature_execution.feature
When a failure occurs, its stack trace is secretly kept inside Cucumber. It should be displayed to the user so that (s)he can actually fix it!
See https://github.com/cucumber/cucumber/wiki/A-Whole-New-World and #2 (comment)
var assert = require('assert');
var defineSteps = function() {
// `this` is set to an object supplying Given, When, Then and the World constructor.
this.World = function World() { this.cukes = 0; }; // this is optional, would default to
// an empty constructor; kinda similar to
// cucumber-ruby's Object instance
this.World.prototype.cukeUp = function() { this.cukes++; };
this.When(/^I cuke up$/, function(callback) {
// `this` is set to the World object
this.cukeUp();
callback();
});
this.Then(/^I should have (\d+) cukes in my belly$/, function(expectedCukes, callback) {
// `this` is set to the World object
assert.equal(this.cukes, expectedCukes);
callback();
});
};
module.exports = defineSteps;
Comments and suggestions are welcome!
./cucumber.js
should accept wildcards. It also runs without parameters and defaults to features/**/*.feature
.
I would expect to see an error message saying "callback not called in /^a variable set to (\d+)$/"
It would be nice to be able to do something like this:
(function(stepdefs) {
// Defines Given, When, Then
stepdefs.register(this);
// Or maybe we have to do it like this:
var Given = When = Then = stepdefs.register;
var cukes;
Given(/I have (\d+) cukes in my belly/, function(n, callback) {
cukes = n;
callback();
});
// More stepdefs here...
})(require('cucumber/stepdefs'));
The code is currently packaged as a single .js file. This Is Bad™. RequireJS seems to be the answer as it handles modules equally within browsers and Node.js (with fallback to native Node module system).
Add --strict flag to CLI and equivalent option to volatile configuration.
Consider the stepdef in example/index.html:
Given(/a variable set to (\d+)/, function(number, callback) {
variable = parseInt(number);
callback();
});
If I replace this with:
Given(/a variable set to (\d+)/, function(number, callback) {
variable = parseInt(number);
setTimeout(function() {
callback();
}, 0);
});
then I get an exception.
Just like big bro: cucumber/common#74
require('zombie');
var World = function(callback) {
this.browser = new zombie.Browser(); // this.browser will be available in step definitions
this.visit = function(url, callback) {
this.browser.visit(url, callback);
};
callback(this); // tell Cucumber we're finished and what to use as World (this)
};
exports.World = World;
but, zombie isn't assigned until you do it yourself:
var zombie = require('zombie');
var World = function(callback) {
this.browser = new zombie.Browser(); // this.browser will be available in step definitions
this.visit = function(url, callback) {
this.browser.visit(url, callback);
};
callback(this); // tell Cucumber we're finished and what to use as World (this)
};
exports.World = World;
Import those scenarios locally:
cucumber-attic/cucumber-tck@1288b20#L1L63
cucumber-attic/cucumber-tck@1288b20#L1L73
Add support for all Gherkin's spoken languages. The # language: xx
comment directive should be recognized.
This will probably impact the undefined step definition snippets.
It looks like the first quoted string is properly substituted to a parameter but not the following ones.
See the JSON section of https://github.com/cucumber/gherkin/wiki/Code-Completion
Add support for tags on features and scenario; filter based on those tags.
Support comment lines as specified in https://github.com/cucumber/cucumber/wiki/Gherkin
Currently, cucumber.js CLI uses a bare "pretty" formatter to output results. It displays the source of the feature while it is running. It is too verbose and does not include any summary.
By default, CLI must use a progress formatter that outputs things in a similar fashion than its Ruby brother (dots and chars to indicate step execution results).
This is how the World constructor is now expected to call back:
this.World = function World(callback) {
callback(this);
}
Calling back without a parameter is currently forbidden, leading to an exception:
this.World = function World(callback) {
callback(); // error!
}
Cucumber is using the new
keyword when calling the World()
function. It means it could (and should) use the fresh World instance when no explicit one is passed to the callback.
this.World = function World(callback) {
callback(); // would be the same as: callback(this)
}
A new project has been created for html reporting for all cucumber implementations. Make cucumber.js use it.
There is already a proof-of-concept.
Basically, cucumber-js needs a new listener that will pass translated events to the cucumber-html formatter and reporter.
Given step definitions currently rely on failures in step definitions to be synchronous:
support_code/step_definitions.js:19
try {
code.apply(world, parameters);
} catch (exception) {
if (exception)
Cucumber.Debug.warn(exception.stack || exception, 'exception inside feature', 3);
var stepResult;
if (exception instanceof Cucumber.Runtime.PendingStepException)
stepResult = Cucumber.Runtime.PendingStepResult()
else
stepResult = Cucumber.Runtime.FailedStepResult(exception);
callback(stepResult);
}
It's not possible to handle assertions that need to be made in callbacks, which is the case when using phantomjs as the bridge is asynchronous. So:
this.browser.evaluate(function(){ "$('#id').length"}, function(result) {
result.should.not.eql(0)
});
Won't fail the scenario if the assertion fails.
Seems like the best approach is to support firing an error event in the case of doing assertions in callbacks (as well as directly throwing exceptions in step definitions. Thoughts? Happy to work on this once we flush out the ideal approach.
It's currently not possible to load more than one feature with the volatile configuration, making it impossible to run a feature suite in memory-only environments like browsers.
Right now the data table parser assumes everything is a string and users have to manually convert fields to Booleans, objects, arrays, etc. More than willing to help out on this if you can point me in the right direction.
I've traced it back to this line:
https://github.com/cucumber/cucumber-js/blob/master/lib/cucumber/type/hash_data_table.js#L33
It looks like Gherkin is actually converting everything to strings, so I'm not sure if that's a bug or something intentional.
cucumber-features + Aruba is now the official way of testing cucumber.js. This is great. But it would even be nicer to have cucumber.js test itself again, like in its early days. Remember: it emerged by testing itself :)
To achieve this we need:
Of course, running cucumber-features with cucumber.js won't generate the nice documentation we get from Aruba.
Also, the step definitions won't run the cucumber.js CLI but will directly load a Cucumber.js instance in-memory. At least for now.
It's getting messy there.
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.