1

Suppose I have a web application, which uses jQuery for Ajax and UI. Now I would like to add unit-tests to it. I would like the unit-tests to run in a single process without launching browsers and separate web servers and I hope it is doable with the Node.js and the following Node.js modules:

  • buster.js
  • jQuery Node.js module
  • jsdom Node.js module

Am I missing something? Is there any example of such unit tests?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Michael
  • 10,185
  • 12
  • 59
  • 110

2 Answers2

2

Try the "assert" module. It's included in standard Node.js, and you can do something like:

var assert = require('assert');
assert.ok(true, 'test fails');
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
sgmonda
  • 2,615
  • 1
  • 19
  • 29
1

Well, you can write your test routines with assert, but I'd like to recommend using unit-testing frameworks - more specifically, nodeunit. There's a neat article describing how to use this module to simplify unit testing.

And may I say there's actually a bunch of threads here with (ahem...) the same question - for example, this one, with plenty of choices. )

Community
  • 1
  • 1
raina77ow
  • 103,633
  • 15
  • 192
  • 229