2013-09-22 15 views
6

Czy można uruchomić tylko jeden test z pliku testowego nodeunit z kilkoma testami. Moja tests.js file:uruchomić jeden test według nazwy z jednego pliku nodeunit

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

mogę uruchomić wszystkie testy:

$ nodeunit tests.js 

Ale chcę uruchomić tylko test2 jak:

$ nodeunit tests.js test2 

Czy to możliwe bez spliting plik tests.js w 2 oddzielnych akta?

Odpowiedz

6

Zobacz nodeunit -h dla dostępnych opcji (jest to dla wersji 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 

więc od tego, co następuje powinien robić to, co chcesz:

$ nodeunit tests.js -t test2 

np :

$ nodeunit ./tests.js -t test2 

tests.js 
test2 
✔ test2 
Powiązane problemy