Closed robkinyon closed 8 years ago
It may be confusing, but in Karma tests you do not drive browser. Karma tests allows you to execute test code inside browser, so you have direct access to front-end code. E.g. you could test view models (of MVVM) from front-end by accessing them directly.
This is different from driving browser. Driving browser is usually used for end to end tests. In those tests you do not have access to view models of application, you only could simulate user input and query DOM. For such tests you do not need Karma, just plain cucumber.js is enough.
My intention here was to use Karma as a browser manager, similar to how Selenium and WebDriver function. I really like Karma for unit tests and was hoping to keep using it for E2E tests, reducing the number of different tools a single project needs to work with.
From your response, it appears that there is no intention of allowing the test to drive the browser similar to how Selenium and WebDriver function. Is that true?
Yes, it is true. Karma tests are executed inside browser but to drive browser you need to be outside of browser.
@robkinyon If you want to acceptance tests with step definitions that are implemented with Selenium WebDriver for AngularJS or Angular 2 apps you should check out the project for the "cucumberized" protractor framework.
As eugene said above, this project "cucumberizes" karma, and the step definitions here are meant to be implemented by injecting your Angular objects and called their public methods.
The standard "Hello World" for Cucumber scenarios is visiting Google and either executing a search or checking the title or whatever. This demonstrates a complete walking skeleton, including integration with Selenium/WebDriver as a browser manager.
In this case, Karma is the browser manager - it handles launching Phantom, Karma, etc. But, I'm at a loss as to how I'm supposed to drive the browser. I don't have a browser object, so I'm not sure what I'm supposed invoke.
Could you provide an example for a feature like: