-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example showing how to test a web application #23
Comments
Hey Mike, Thank you for the suggestion. Cucumber.js is - as you probably know - running within both Node.js and web browsers. A little example exists already (run There are two ways (probably others?) of using cucumber.js to run against a web app: Inside browsersThis is one way to test web applications: run cucumber on top of your application, inside the browser. Pros
Cons
Inside Node.jsAnother way to run features against a web app - as you are suggesting - is to run the features from within Node.js (i.e. this is the headless approach). You might use a lib like the awesome zombie.js to browse the app and interact with it from the step definitions. Pros
Cons
I like the idea of having demos for both approaches, it would definitely help people understand how this is all working. It would be great if someone could send a pull request for this. I am currently polishing the cucumber.js' own test suit. Following that, I plan on adding important missing features listed in the 0.2 release issue list (tables, background, etc.). Don't hesitate to ping me on #cucumber if you need more specific help to test your app! Cheers. |
This is extremely helpful. Ideally we would have something like capybara, On Thu, Jul 28, 2011 at 5:39 AM, jbpros <
|
I've put together a small demo. It's just a start. Next thing: add a complete README documenting it all. |
Hi, I setup an example app here. It's just a start as well. Running the features is explained in the README, you can browse the setup for cucumber in |
@olivoil Nice work! Thank you for sharing this. You could improve the way World is handled. Instead of returning an instance of your World when exporting the module, you would export the constructor and let Cucumber instantiate it. The benefit of it is that Cucumber will instantiate a new object for each scenario. This will guarantee a clean state between scenarios. |
… application. Fixes cucumber#23
@jbpros Thanks for the tip! I'll push the changes tonight :) I included a pull-request to update the readme with more usage information. Hope this helps! |
@jbpros |
There is nothing built into cucumber specifically to do that. Cucumber connects the gherkin in the feature files to JavaScript functions and outputs the results. Writing the functions that clicks and the function that verifies the API was called is up to you. There are plenty of other libraries out there that should be able to help. From a testing standpoint, it might make sense to have your tests hit a local deployment or a mock version of your API. After you click the proper button, you can check that the API method was called (if using a mock) or the effect of calling the API method (if using a local deployment) |
Thanks much @charlierudolph ! |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
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
The text was updated successfully, but these errors were encountered: