ava test
This example compares the TAP output of the AVA test runner with that of the `tape` and `tap` libraries, highlighting inconsistencies in console log placement and stream routing. It shows that AVA emits console logs before test titles and writes them to stderr, while `tape` and `tap` place logs after titles on stdout. The visualization uses the `console.log` calls within each test to trace the order and destination of output, contrasting the raw TAP streams side by side. The code relies on the test APIs of `ava`, `tape`, and `tap` to produce the compared outputs.
AI-generated descriptionDescription
The TAP output from AVA is inconsistent with other TAP producers in two ways.
- Console logs within a test appear before the test title.
- Console logs within a test are written to stderr.
Forgive me if either of these are a feature or reported before. There are many issues that may be related (example https://github.com/avajs/ava/issues/392) but I couldn't find any that are exactly these issues.
Below I compare the output of ava's TAP reporter to substack/tape. I see the same inconsistency when comparing to tapjs/node-tap.
Test Source
In ava: (using test.cb for comparison).
var test = require('ava');
test.cb('ava test', function (t) {
console.log('inside ava test');
t.pass();
t.end();
});
test.cb('ava test #2', function (t) {
console.log('inside ava test #2');
t.pass();
t.end();
});
test.cb('ava test #3', function (t) {
console.log('inside ava test #3');
t.pass();
t.end();
});
outputs:
TAP version 13
inside ava test
# ava test
ok 1 - ava test
inside ava test #2
# ava test #2
ok 2 - ava test #2
inside ava test #3
# ava test #3
ok 3 - ava test #3
1..3
# tests 3
# pass 3
# fail 0
Notice that the "inside ava test" console logs appear before the test title. Additionally, the console logs are output to stderr which makes it difficult to work with TAP consumers (for example https://github.com/Hypercubed/tap-markdown).
in tape:
var test = require('tape');
test('tape test', function (t) {
console.log('inside tape test');
t.pass();
t.end();
});
test('tape test #2', function (t) {
console.log('inside tape test #2');
t.pass();
t.end();
});
test('tape test #3', function (t) {
console.log('inside tape test #3');
t.pass();
t.end();
});
outputs:
TAP version 13
# tape test
inside tape test
ok 1 (unnamed assert)
# tape test #2
inside tape test #2
ok 2 (unnamed assert)
# tape test #3
inside tape test #3
ok 3 (unnamed assert)
1..3
# tests 3
# pass 3
# ok
Console logs are output after titles and to stdout.
Command-Line Arguments
For ava:
ava ./ava-test.js --tap --serial
For tape:
tape ./tape-test.js
Environment
Node.js v6.2.1
darwin 15.2.0
ava 0.15.2
npm 3.9.3