Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run one test by name from one nodeunit file

Tags:

nodeunit

Is it possible to run only one test from nodeunit test file with several tests. My tests.js file:

module.exports = {
    test2: function (test) {
        console.log ("test2")
        test.done();
    },
    test1: function (test) {
        console.log ("test1")
        test.done();
    }
};

I can run all tests:

$ nodeunit tests.js

But I want to run only test2 like:

$ nodeunit tests.js test2

Is it possible without spliting file tests.js into 2 separate files?

like image 304
Maxim Yefremov Avatar asked Sep 22 '13 16:09

Maxim Yefremov


Video Answer


1 Answers

See nodeunit -h for the available options (This is for version 0.8.1):

Usage: nodeunit [options] testmodule1.js testfolder [...]
Options:

  --config FILE     the path to a JSON file with options
  --reporter FILE   optional path to a reporter file to customize the output
  --list-reporters  list available build-in reporters
  -t name,          specify a test to run
  -f fullname,      specify a specific test to run. fullname is built so: "outerGroup - .. - innerGroup - testName"
  -h, --help        display this help and exit
  -v, --version     output version information and exit

So from that the following should do what you want:

$ nodeunit tests.js -t test2

e.g:

$ nodeunit ./tests.js -t test2

tests.js
test2
✔ test2
like image 158
muffinresearch Avatar answered Nov 04 '22 00:11

muffinresearch