6

複数のテストを含む nodeunit テスト ファイルから 1 つのテストのみを実行することは可能ですか。私の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つの別々のファイルに分割せずに可能ですか?

4

1 に答える 1

6

利用可能なオプションについては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

例えば:

$ nodeunit ./tests.js -t test2

tests.js
test2
✔ test2
于 2013-10-22T16:30:10.903 に答える