Javascript 有没有办法控制casper';s控制台输出?

Javascript 有没有办法控制casper';s控制台输出?,javascript,unit-testing,casperjs,Javascript,Unit Testing,Casperjs,只是想知道是否有可能强制casperjs只向控制台输出失败的测试。 有人试过这样做吗 谢谢因为您正在运行CasperJS测试环境,所以在运行CasperJS时可以添加: casperjs test --concise yourTest.js 这会隐藏所有断言日志,但不会隐藏失败的其他信息: Test file: test20_only_show_fail.js # type: assert # file: test20_only_show_fail.js:8 # code:

只是想知道是否有可能强制casperjs只向控制台输出失败的测试。 有人试过这样做吗


谢谢

因为您正在运行CasperJS测试环境,所以在运行CasperJS时可以添加:

casperjs test --concise yourTest.js
这会隐藏所有断言日志,但不会隐藏失败的其他信息:

Test file: test20_only_show_fail.js # type: assert # file: test20_only_show_fail.js:8 # code: test.assert(false, "false"); # subject: false # type: assert # file: test20_only_show_fail.js:13 # code: test.assert(false, "false"); # subject: false FAIL 3 tests executed in 0.027s, 1 passed, 2 failed, 0 dubious, 0 skipped. 这将生成附加信息后面的故障线:

Test file: test20_only_show_fail.js # type: assert # file: test20_only_show_fail.js:7 # code: test.assert(false, "false"); # subject: false FAIL false # type: assert # file: test20_only_show_fail.js:12 # code: test.assert(false, "false"); # subject: false FAIL false FAIL 3 tests executed in 0.028s, 1 passed, 2 failed, 0 dubious, 0 skipped.
我现在看到的是casperjs在控制台中为单元测试中通过的每个断言编写PASS+“some message”。我需要知道如何使casperjs在控制台中只输出失败消息(对于某些失败的断言)。 Test file: test20_only_show_fail.js # type: assert # file: test20_only_show_fail.js:7 # code: test.assert(false, "false"); # subject: false FAIL false # type: assert # file: test20_only_show_fail.js:12 # code: test.assert(false, "false"); # subject: false FAIL false FAIL 3 tests executed in 0.028s, 1 passed, 2 failed, 0 dubious, 0 skipped.
casper.test.on("fail", function(failure) {
    this.casper.echo("FAIL " + failure.message);
});

casper.test.begin('fail test', function(test) {
    test.assert(true, "true");
    test.assert(false, "false");
    test.assert(true, "true (2)");
});

casper.test.begin('error test', function(test) {
    test.assert(false, "false");
});