Multiple reporters


可以多次指定 --test-reporter 标志,以多种格式报告测试结果。 在这种情况下,需要使用 --test-reporter-destination 为每个报告者指定目的地。 目标可以是 stdoutstderr 或文件路径。 报告器和目的地根据指定的顺序配对。

在下面的例子中,spec 报告器将输出到 stdoutdot 报告器将输出到 file.txt

node --test-reporter=spec --test-reporter=dot --test-reporter-destination=stdout --test-reporter-destination=file.txt

当指定单个报告者时,目的地将默认为 stdout,除非明确提供目的地。

The --test-reporter flag can be specified multiple times to report test results in several formats. In this situation it is required to specify a destination for each reporter using --test-reporter-destination. Destination can be stdout, stderr, or a file path. Reporters and destinations are paired according to the order they were specified.

In the following example, the spec reporter will output to stdout, and the dot reporter will output to file.txt:

node --test-reporter=spec --test-reporter=dot --test-reporter-destination=stdout --test-reporter-destination=file.txt

When a single reporter is specified, the destination will default to stdout, unless a destination is explicitly provided.