renier
2012-05-24 22:01:01 UTC
Hello,
This email is meant to get a feel of the level of interest and potential
concerns with making cucumber.js loadable with require.js-style functions
in the browser.
Currently running cucumber.js in the browser depends on running a node.js
server. The current approach is to use Browserify (a node module) to create
the commonjs functions (require, define) that the browser can use to load
the cucumber library, plus it inlines the whole library using these
functions.
While this allows cucumber.js to run in a browser, the global definition of
the require/define functions creates conflicts in the browser if you are
already using a JavaScript toolkit with AMD support that defines these
functions. Cucumber should be able to run within a browser without any
server runtime restrictions other than static file serving. It should also
work with any set of require/define functions without needing to specify
its own.
require.js support for cucumber.js means that we remove the hard dependency
on node without harming the ability to run within node. So if you are
already using a browser JavaScript toolkit that supports AMD (e.g. jQuery,
Dojo, require.js, etc.), you could load the cucumber.js library from
anywhere (like a CDN site) and have it work seamlessly with your other
loaded modules.
This support actually already exists at
https://github.com/cucumber/cucumber-js/tree/requirejs. Need people to try
the example out and comment on the general approach. A quick summary below:
* With the exception of the CLI library (which needs a server-side
JavaScript runtime anyway and which better than Node or any other strict
commonjs implementation), wrap all the modules in require.js-style
functions that return a reference to their export.
* Use the amdefine[1] node module to make modules wrapped in a
require.js-style function still loadable by node.
That's pretty much it. Oh and this also makes cucumber.js embeddable in
your JavaScript projects and you can use any number of tools from any
number of toolkits to optimize/inline/minify the cucumber library as part
of your normal build practices or as a one-time-only thing.
This also makes it possible to inject cucumber into a web page using a
headless browser to run your acceptance tests. But that is another story :-)
Thoughts?
-Renier
[1] http://requirejs.org/docs/node.html#nodeModules
-- There are two rules:
1) Please prefix the subject with [Ruby], [JVM] or [JS]. This allows people to filter messages.
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cukes-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org To unsubscribe from this group, send email to cukes+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
This email is meant to get a feel of the level of interest and potential
concerns with making cucumber.js loadable with require.js-style functions
in the browser.
Currently running cucumber.js in the browser depends on running a node.js
server. The current approach is to use Browserify (a node module) to create
the commonjs functions (require, define) that the browser can use to load
the cucumber library, plus it inlines the whole library using these
functions.
While this allows cucumber.js to run in a browser, the global definition of
the require/define functions creates conflicts in the browser if you are
already using a JavaScript toolkit with AMD support that defines these
functions. Cucumber should be able to run within a browser without any
server runtime restrictions other than static file serving. It should also
work with any set of require/define functions without needing to specify
its own.
require.js support for cucumber.js means that we remove the hard dependency
on node without harming the ability to run within node. So if you are
already using a browser JavaScript toolkit that supports AMD (e.g. jQuery,
Dojo, require.js, etc.), you could load the cucumber.js library from
anywhere (like a CDN site) and have it work seamlessly with your other
loaded modules.
This support actually already exists at
https://github.com/cucumber/cucumber-js/tree/requirejs. Need people to try
the example out and comment on the general approach. A quick summary below:
* With the exception of the CLI library (which needs a server-side
JavaScript runtime anyway and which better than Node or any other strict
commonjs implementation), wrap all the modules in require.js-style
functions that return a reference to their export.
* Use the amdefine[1] node module to make modules wrapped in a
require.js-style function still loadable by node.
That's pretty much it. Oh and this also makes cucumber.js embeddable in
your JavaScript projects and you can use any number of tools from any
number of toolkits to optimize/inline/minify the cucumber library as part
of your normal build practices or as a one-time-only thing.
This also makes it possible to inject cucumber into a web page using a
headless browser to run your acceptance tests. But that is another story :-)
Thoughts?
-Renier
[1] http://requirejs.org/docs/node.html#nodeModules
-- There are two rules:
1) Please prefix the subject with [Ruby], [JVM] or [JS]. This allows people to filter messages.
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cukes-/JYPxA39Uh5TLH3MbocFF+G/***@public.gmane.org To unsubscribe from this group, send email to cukes+***@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en