Conversation
If the yml file contains a `require_js` element with the url fragment to require.js, then the server will switch to CommonJS amd module mode. It will no longer directly load any source files, but will expect that the specs are declared as modules taking dependencies on the appropriate source files.
I did not add an example section in the yml file. I think I saw more than one and wasn't sure which to modify. |
Be sure to add a single item to the yml file, not a list:
not
|
Unless I'm mistaken, it looks like this will have the helpers loading before the src files that are required. That's not how it worked before, with the src files before the helpers. Helpers may use code from the src files. |
True enough. I should remove the loading of helpers all together and let require.js handle the loading. Then any dependencies /load order issues can be taken care of correctly. |
Modified the erb to expect that the require.js configuration be an array. Now any require.js configuration can be done prior to using require.js.
There, now it ignores helpers. It works fine to simply require the helpers needed, and if they need access to the code under test, they can just require those modules. Also, now the require_js configuration option is expected to be an array. If something must load before the specs, it can be put there. |
Will this get merged to the official gem at some point? |
Probably not as is. This works for us but I think it's best thought of as a proof if concept. |
Yeah, I feel like it's best for us to put off addressing this issue until the next release, where we can take on all the new JS challenges that Rails 3.1 and other frameworks are now presenting. Apologies for making it difficult for those of you that use require_js, but we want to get 1.1 (mostly bugfixes and a minor gem refactor) out within the week. We'll probably have a substantial refactoring of Jasmine coming soon, as it's getting pretty creaky. |
Another thing to keep in mind when enabling require_js support for real: https://github.com/JamesMaroney/requirejs-isolate This plugin helps to isolate the code under test. |
Now that Jasmine is at 1.1, can we get this issue reopened? jwhitley's requirejs-rails gem is now at 0.5.1 and one of the items slated for the 1.0 build is jasmine support. From what I've grokked so far, the only way to get require.js support working in his gem would be to get support for require.js into the jasmine gem. |
@malandrew Meanwhile: https://github.com/millermedeiros/amd-utils/tree/master/tests perhaps this may help someone |
I'd love to see some official support, too! |
+1 for require.js support. We're in the process of trying to hack a solution together, but it would be nice to have official support. |
+1 for reopening |
We still plan on better async loading support in a future release. In the meantime: https://github.com/mattfysh/testr.js is your best bet. |
If the yml file contains a
require_js
element with the url fragment to require.js, then the server will switch to CommonJS amd module mode.It will no longer directly load any source files, but will expect that the specs are declared as modules taking dependencies on the appropriate source files.
Anyone interested in playing with this, I have a gem you can try out:
https://github.com/downloads/brendanjerwin/jasmine-gem/jasmine-1.0.3.0pre.gem