запустить один тест по имени из одного файла nodeunit

Можно ли запустить только один тест из тестового файла nodeunit с несколькими тестами. Мой tests.js файл:

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

Я могу запустить все тесты:

$ nodeunit tests.js

Но я хочу запустить только test2, например:

$ nodeunit tests.js test2

Можно ли не разбивать файл tests.js на 2 отдельных файла?


person Maxim Yefremov    schedule 22.09.2013    source источник


Ответы (1)


Доступные параметры см. в разделе nodeunit -h (это для версии 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

Итак, следующее должно делать то, что вы хотите:

$ nodeunit tests.js -t test2

e.g:

$ nodeunit ./tests.js -t test2

tests.js
test2
✔ test2
person muffinresearch    schedule 22.10.2013