let me know if you find a solution. After converting ACE <https://github.com/ajaxorg/ace> to requireJS all our jsTestDriver stopped working. I have found no easy way to use it together with requireJS. I'm very interested in your findings.
On Mon, Dec 13, 2010 at 1:18 AM, Aaron Greenlee <aarongreen...@gmail.com> wrote: > I am curious, if anyone is using JSTestDriver with their RequireJS > projects?
> JSTestDriver seems to run all the tests within a single instance-- > which has led me to wrap each unit test within it's own RequireJS > context.
> I have a feeling I am over complication things and was hoping someone > could share an example.
> The application and I am experimenting with includes RequireJS and > Backbone.JS with tests powered by JSTestDriver from Eclipse.
RequireJS can not play with JSTestDriver. No script loader can without introducing some kind of build process. JSTestDriver acts as it's own server and will not respond to script or Ajax requests. I was able to get a ugly sample up and running by mocking the 'define()' and 'require()' methods, but, I don't think I like this approach as it forces me to inject the real code inside a RequireJS module during a build process to allow the code to execute within my test environment. Here is my quick sample test for JSTestDriver:
SampleTest.prototype.setUp = function () { // Mock RequireJS -------------------------------------------------------------- rjsMock = {}; require = function (mdl) { var request = rjsMock[mdl]; return request;
I really enjoy using JSTestDriver since it makes testing multiple browsers so easy and fast. But, I am close to giving up and getting these two to play nice. At one point, JSTestDriver supported a 'serve' attribute which would have allowed this; however, it appears to have been removed to keep the unit tests "pure".
On Mon, Dec 13, 2010 at 3:02 PM, Aaron Greenlee <aarongreen...@gmail.com> wrote: > RequireJS can not play with JSTestDriver. No script loader can without > introducing some kind of build process. JSTestDriver acts as it's own server > and will not respond to script or Ajax requests. I was able to get a ugly > sample up and running by mocking the 'define()' and 'require()' methods, > but, I don't think I like this approach as it forces me to inject the real > code inside a RequireJS module during a build process to allow the code to > execute within my test environment. Here is my quick sample test for
I am not familiar with JSTestDriver, it seems like it is focused on very small unit tests. How would tests that involve data requests via XHR work, or are they not allowed?
I have been thinking of trying out the updated YUI Test[1] that does not depend on YUI, and Yeti[2] for driving the tests. I'm not sure if Yeti works with the new YUI, but Ben Lowery was able to do some sort of adapter that works for Dojo[3] that allows the use of Yeti.
I know that switching test frameworks is not fun though. I'm open to entertaining getting something to work with JSTestDriver, but if it cannot even do XHR/JSONP tests, not sure there is much hope in finding a solution, unless you run the RequireJS optimizer to collect all the scripts together, as Aaron mentioned.
After discussing the issue on the JSTestDriver Google Group, I expect they will make some changes to better support script loaders.
JSTestDriver does work "out-of-the-box" but it is not designed to be a test framework. JSTestDriver is really more of a test runner supporting YUI Test, QUnit, Jasmine, Ruby Auto Teast, Team City and really any other testing framework. It works via the command line, from Eclipse or from within IntilliJIDEA and makes it very easy (and fast) to test in all major browsers. You can learn more here: http://code.google.com/p/js-test-driver/
On a side note, I've been waiting for an opportunity to introduce it into my work since seeing your presentation at the jQuery confernece at Microsoft last April. I appreciate you contributing this to the community. Thanks!
> I am not familiar with JSTestDriver, it seems like it is focused on > very small unit tests. How would tests that involve data requests via > XHR work, or are they not allowed?
The last time I checked jsTestDriver did not allow async tests and it seems to me that they don't even want them to keep the tests pure.
> I have been thinking of trying out the updated YUI Test[1] that does > not depend on YUI, and Yeti[2] for driving the tests. I'm not sure if > Yeti works with the new YUI, but Ben Lowery was able to do some sort > of adapter that works for Dojo[3] that allows the use of Yeti.
That would be awesome. Yeti looks to me like the better jsTestDriver.