3

We are looking for a Javascript test framework that can execute tests across the entire application stack, on the client as well as the server. We are using jQuery, RequireJS and Backbone.js on the client, and Node.js and express on the server.

Node.js is supposed to simplify creating web application by providing a more similar setting to both client side and server side development by using the same language (among it's other goals). However, I found it hard to unit test and come up with a consistent set of technologies that work on the client and server.

Currently, we are using QUnit for testing on the client and Expresso and Should.js on the server. They have totally different interfaces, which make it very difficult to test code that is shared between the client and server. Consider for example a module that does validation, both the client and the server need access to this and both need to unit test on all clients and the server.

Essentially, I am looking for that holy grail that allows us to develop web application in a similar fashion that client-server application are developed in languages like python and ruby.

Michael Yagudaev
  • 6,049
  • 3
  • 48
  • 53
  • I thought that there is currently no agreed standard for handling modules for both client and server side. There is AMD for asynchronous module declaration (used on the client side), and then there are the modules in node.js that uses the proposed implementation in commonjs – badunk May 21 '12 at 18:03
  • 1
    @badunk you are right, that is also a problem. But, it is now possible to use RequireJS on the server-side. We haven't done that yet. Node.js uses a synchronous require. There is a proposal for async one called require.ensure() here: http://wiki.commonjs.org/wiki/Modules/Async/A.RequireJS is pretty simple after you get used to it and its author is really committed to making it better. – Michael Yagudaev May 21 '12 at 19:01
  • @yaudaev neat! thanks for the tip ;) – badunk May 21 '12 at 20:39

1 Answers1

1

It sounds like you're looking for something like BusterJS which has server-side and client-side components. You would have a separate set of tests for each part, but the syntax would remain consistent. You'd just specify your env in the buster.js config like so:

env: "browser", // or "node"

This is by far my favorite choice from all available frameworks right now.

Eric Wendelin
  • 43,147
  • 9
  • 68
  • 92
  • This looks like a great tool. I'm definitely going to check that out. – Moses May 21 '12 at 18:04
  • Thanks Eric. It looks a little young, but hopefully by end of this month they will actually get a 1.0 out that is stable. I like the ideas they have for it :). Just want to make sure we can trust the test results not to return false positives or crash. What do you mean by "You would have a separate set of tests for each part"? Why? – Michael Yagudaev May 21 '12 at 19:04
  • @yagudaev What I mean is that you'd have one set of tests configured to run in "browser" mode, and another set of tests that ran in "node" mode using require etc. As far as maturity, I have not had any problems at all since 0.5.1 and I'm using it for production apps. – Eric Wendelin May 21 '12 at 19:22
  • Watching the video on the site now, buster is truly brilliant. It does do all the stuff I was looking for :). I'll accept this answer, would be nice to get a few more alternatives just for completeness. – Michael Yagudaev May 21 '12 at 19:58