s9tpepper / karma-cucumberjs

A Cucumber.js Karma test runner adapter.
MIT License
54 stars 21 forks source link

Breaks when `browserify --standalone` bundle included via karma files #12

Open beckyconning opened 10 years ago

beckyconning commented 10 years ago

As a karma-cucumber-js user I want to include a bundle built with Browserify So that I can use its functionality inside my feature testing DSL

Given a bundle that has been built with Browserify as follows browserify src/some-module.js --standalone some-module > bundle.js When I include this module in karma.conf.js's file section as follows { pattern: "./node_modules/some-module/bundle.js", watched: false, included: true, served: false } I should not be presented with the error Error: Mismatched anonymous define() module

The error originates from here https://github.com/s9tpepper/karma-cucumberjs/blob/master/lib/adapter.js#L1220

beckyconning commented 10 years ago

Seems this has been fixed in a newer RequireJS

https://github.com/jrburke/requirejs/issues/883

Could you possibly update RequireJS in this package?

beckyconning commented 10 years ago

It would be really useful if you could include the build config or even an package.json build script.

beckyconning commented 10 years ago

http://requirejs.org/docs/errors.html#mismatch

justinware commented 9 years ago

Yes I think I tend to agree with you @beckyconning. I am also using a bundled JS file and getting the exact same error. Would be great to get an updated RequireJS in a new build. Have you managed to now get it working ?

beckyconning commented 9 years ago

No I haven't, I ran out of time before I could work it out. I added an npm build script to my local fork which I should probably commit though.

After the project I'm currently working on I'm going to put together the start of another Cucumber.js Karma adapter using the promises version of Cucumber.js and Browserify.

This isn't because this one is bad. This one is awesome but I think @s9tpepper is too busy to maintain it. We depend on this a lot so we're happy to maintain a Cucumber.js Karma adapter and manage PRs etc.

Let me know if you work it out though.

beckyconning commented 9 years ago

I don't think its as simple as updating RequireJS and rebuilding though. I think files are being manually loaded in some fashion that breaks RequireJS when combined with Browserify.

justinware commented 9 years ago

Yeah I was thinking the exact same thing, in that at some point I would write my own Karma adapter utilising the existing CucumberJS and Browserify node packages (as I think the raw CucumberJS package works quite well as it is). Was toying with calling it karma-chameleon :) Why...? because it hasn't been done yet, because it's funny, and because I am child of the 80s and just love that song :)

Pretty busy though, have deliverables and need an immediate solution, so in the interim we are going to look at using Yadda (https://github.com/acuminous/yadda) which seems to be very similar to what CucumberJS offers, Gherkin-like feature specs, supports a plethora of other test framework integration (Jasmine, Mocha, etc), utilises RequiresJS, has documented Karma examples and seems to be pretty progressive, active & well-maintained. Am doing a Spike on it today, and so hopefully is fit for purpose.

justinware commented 9 years ago

Meant utilises browserify...

cmdln commented 9 years ago

I am running afoul of the same issue but would definitely prefer to continue to use something that works with karma since we have approaching 500 unit tests in our existing karma setup.