-
Notifications
You must be signed in to change notification settings - Fork 307
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
Using Cucumber.js with Intern #81
Comments
Is this an enhancement request, or are you asking for support? If you are asking for support, please read information on getting support. If this is an enhancement request I will schedule it into the milestone schedule. |
I’m treating this as an enhancement request. We’ll add a Cucumber interface for 1.4. |
It looks like it wasn't included in 1.4, am I right? |
You are correct. It's been pushed back a couple of releases. |
This would be incredibly helpful and a well used feature if implemented. |
I added basic support for Cucumber in the |
Hi jason0x43, how do I run the inter-cucumber-example tests? and came across the error: |
You should be able to clone that project, run |
You need to be using the intern dependency specified in the project's |
Hi Jason,
|
|
Oh, you mean that sauce key. (I was looking in the wrong repo.) Thanks for the heads up. |
This feature is something my team is very interested in using. Is this still in planning for development? |
It seems that jason0x43 got very close to making this work, but unfortunately I can't get https://github.com/jason0x43/intern-cucumber-example to work now. Are there plans to integrate this into intern? It seems like the new BDD aspect of intern should know how to handle running the feature files, or else it's only BDD-style but doesn't have the benefit of separating user stories and steps. If someone has an example of using cucumber-js as a plugin, that could help too, thanx! |
Thanks for your quick reply. I tried using https://github.com/jason0x43/intern-cucumber-example with a
which loads the last commit on #650 PR. Changing
But I get no output. I've tried typing gibberish into the test files and it throws an error, so I think it is able to find the intern object I was hoping I might be able to feel my way through getting it working, but without an example, I can't really get anywhere. Does someone happen to have a features/steps example I can try? Thanx! UPDATE: I managed to get something working, I evidently just had to ask the universe:Copy:
to:
And change the top lines from
Then change
Here is the output:
So this is at least a starting point. I may end up writing a loading loop to find all feature files in a directory and call registerCucumber() with each of their contents, unless someone knows how to pass the feature files to the cucumber interface another way (jason0x43 passed it in the define as Hope this helps someone. P.S. The reason I used 3d73693 above was to future-proof the dependency, which will work until the repo gets taken down (it's not a permanent solution). |
Apologies, the above workaround may not be necessary. Running
I thought perhaps the difference was Anyway, this provides a starting point. I think that maybe the best thing to do is pull out these cucumber examples from the PRs into their own I'm also thinking that the true power of Intern is this ability to adapt other testing frameworks under a common convention of naming each test and specifying the steps inside of a suite. If you could write object interfaces for the testing frameworks on https://www.browserstack.com/support?tag=automate and https://watirmelon.blog/2015/12/08/comparison-of-javascript-browser-automation-and-test-specification-libraries/ you would really have something. The biggest pain of all of these frameworks is having to repeat yourself writing domain-specific language implementations of tests and then translators between human tasks/accessor functions in page objects. With a consolidated way of trying all these approaches, maybe a better way would evolve out of them. Does anyone have an example of writing an object that calls something like cucumber.js? The learning curve for reporters and executors and stuff is pretty steep. Anyway, hope this helps someone. |
@zmorris To answer a small point from your comment, I often describe Intern's most important feature is that it's a really good glue architecture for combining things that are difficult to combine together normally, in a consistent, flexible, and coherent manner. It's also what I feel Dojo does pretty well, in particular the forthcoming Dojo 2. I would love to address those additions and a number of other things that we don't yet integrate with, as well as finally having a solid answer for Cucumber support! |
@dylans on that note, I decided to make a local object class that calls cucumber.js, like what jason0x43 and rhpijnacker have done except not as a pull request: https://github.com/theintern/intern/blob/cucumber/lib/interfaces/cucumber.js Then I will have page objects import that, treating it like the BDD object you have now. The trickiest part turned out to be loading cucumber.js, because I'm not super familiar with how Node.js modules work. I lost about half a day trying every permutation of https://github.com/amdjs/amdjs-api/blob/master/CommonConfig.md#packages-
but I found that it generally didn't work. I finally stumbled onto this explanation of how dojo works: http://stackoverflow.com/a/21887408/539149 So using intern's dojo to load cucumber.js in the last line of define() like so:
in my local object worked perfectly, and I was able to remove references to cucumber from intern.js. Here is my local package.json:
I still haven't figured out how to use intern's version of dojo when I need to call it directly, for example as 'intern!dojo/aspect' or 'intern!dojo!aspect' so unfortunately I still have dojo added locally. I also couldn't get dojo 2.0.0-alpha.7 to work locally so my version differs from intern's. If anyone knows how to do that, it would be great to get rid of my local dojo dependency. If you could add a note about loading modules in the Intern documentation, it would be super helpful. So after all that, I have cucumber imported but can't get it to work :-/ I think the issue is that since there is no global.window, cucumber isn't setting up its context correctly or something. I don't know if I have to set cucumber up somehow in the runner instead of the object either. I prefer jason0x43's calling convention but since it's 3 years out of date I don't know if I can get it working. It would be so great though to have objects that call other testing frameworks so people could migrate to Intern. |
I couldn't get the
I then downloaded: https://github.com/rhpijnacker/intern/blob/master/lib/interfaces/cucumber.js to <project_root>/cucumber.js changed top lines to:
downloaded: https://github.com/rhpijnacker/intern/blob/master/tests/unit/lib/interfaces/cucumber.js to <project_root>/tests/cucumber.js changed top lines to:
here is my
Here is my output:
The first two tests passed but then it failed due to a promise issue. I tried going in and console.log() the heck out of If you can help me fix this last thing, I'm hopeful I can adapt this to look very much like https://github.com/jason0x43/intern-cucumber-example by adapting parts from the cucumber branch so the Given(), When(), Then() calls are in the test suite and it loads feature files. But I just can't seem to figure out the promises issue. Thanks for all your help so far. |
Hi @zmorris, wondering if you managed to get this working? Been trying to find any latest news on using Cucumber with Intern but the trail seems to end here, but am really interested in being able to use it. |
@jordangarvey Sorry for my late response, I just found out about https://github.com/notifications/participating haha. I had the same problem and implementing a solution would have required digging further into the Intern internals than I could muster. I ended up going with WebDriverIO running Mocha/Chai and Yadda on top of that. The core problem here (that I've seen repeated over and over again in nearly all testing frameworks) is that BDD should have been a layer over TDD, not an alternative. So we shouldn't need a separate runner for Gherkin/Cucumber. We should be able to call out to a features/steps loader from within our unit tests, running TDD and/or BDD suites in one pass and printing all results through the same reporter, which is precisely what Yadda does. To me, this is why BDD never caught on at nearly the level that it should have. The main aha moment for me is that BDD is for setting up context for the tests. This is perhaps more important than the human-readable aspect of it. Context and mocking turn out to be the primary challenges with things like acceptance testing, and TDD generally only addresses mocking, which severely limits it in practice. |
@jordangarvey, @zmorris Maybe you want to check out https://github.com/rhpijnacker/intern-cucumber. This is a re-implementation of the earlier integration of cucumber-js for intern 4. The module is now available as a separate npm package and is loaded as a plugin. |
I am having trouble with implementing Before, BeforeAll, After and AfterAll using TypeScript. @rhpijnacker has advised TypeScript does not expose the After, AfterAll, Before and BeforeAll properties and to make changes to .d.ts file with these methods but I need more info on what the parameters are. Also should these be implemented as a hook or within the step definition file. It would also be helpful to know if tags and hooks are part of intern-cucumber and how these are run on the command line. Any help would be gratefully appreciated. Here is what my plugin.d.ts originally looked like: export interface World { export default function registerCucumber( export function Given(pattern: RegExp | string, code: StepDefinitionCode): void; export interface CucumberInterface {
} |
@dsb3ar I based the typescript typings on https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/cucumber/v3/index.d.ts. So you may want to have a look at how Before and After are defined there. |
@zmorris Are you using Yadda with intern? I've been trying to get intern working with cucumber for ages and I've had no luck. I'm having trouble using cucumber as a plugin or loader, as I am working with karma as well, as my test runner, so adding intern plugins or loaders has been difficult since I already have a karma config file... if cucumber or yadda were already an interface option for me, this would work. Any ideas on how to implement this myself? |
I'm closing this (finally) given the existence of https://github.com/rhpijnacker/intern-cucumber. An external plugin seem like the best place for this functionality for now. |
Hi!
Is it possible to use Cucumber.js ( https://github.com/cucumber/cucumber-js ) together with intern? I would like to write my functional tests as features in pure Gherkin Syntax. What I have to do if I want to use Cucumber.js?
Regards!
The text was updated successfully, but these errors were encountered: