File: nodeunit-overview.md

package info (click to toggle)
node-grunt-contrib-nodeunit 4.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 416 kB
  • sloc: javascript: 363; makefile: 4
file content (20 lines) | stat: -rw-r--r-- 1,310 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Task targets, files and options may be specified according to the grunt [Configuring tasks](http://gruntjs.com/configuring-tasks) guide.

This plugin provides server-side JavaScript unit testing via [nodeunit](https://github.com/caolan/nodeunit/). If you're looking to test JavaScript that uses `window` or the DOM, please use the [grunt-contrib-qunit plugin](https://github.com/gruntjs/grunt-contrib-qunit)`qunit` task.

# Differences from Nodeunit Command Line

There may be a few differences versus running `nodeunit` on the command line:

## Undone tests will cause problems

Nodeunit's reporters (such as `default`) are in charge of tracking tests that do not complete.  They often hook
into `process.on('exit')`.  Since `grunt` is handling the runtime, it does not exit, so the reporter's clean-up code
that monitors undone tests does not fire.  Additionally, the reporters do not expose the number of "Undone" tests in their
completion callbacks.

This can cause problems.  For example, if an exception is thrown in an undone test, the exception might bubble up into the
`grunt` runtime if it's still running.  This would cause `grunt` to exit, while `nodeunit` command line would show the undone 
test.

If you're getting strange `grunt` runtime errors or seeing `grunt` exit, check for "undone" tests.