Skip to content

Instantly share code, notes, and snippets.

@Hypercubed
Last active June 15, 2016 03:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hypercubed/96db4034dbf80317c3e9d2864265b519 to your computer and use it in GitHub Desktop.
Save Hypercubed/96db4034dbf80317c3e9d2864265b519 to your computer and use it in GitHub Desktop.
node_modules

Description

The TAP output from AVA is inconsistent with other TAP producers in two ways.

  1. Console logs within a test appear before the test title.
  2. 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 avajs/ava#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
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();
});
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
{
"name": "tape-ava-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"ava": "^0.15.2",
"tap": "^5.7.2",
"tape": "^4.5.1"
}
}
var tap = require('tap');
tap.test('tap test', function (t) {
console.log('inside tape test');
t.pass();
t.end();
});
tap.test('tap test #2', function (t) {
console.log('inside tape test #2');
t.pass();
t.end();
});
tap.test('tap test #3', function (t) {
console.log('inside tape test #3');
t.pass();
t.end();
});
TAP version 13
# Subtest: ./tap-test.js
# Subtest: tap test
inside tape test
ok 1 - (unnamed test)
1..1
ok 1 - tap test # time=5.055ms
# Subtest: tap test #2
inside tape test #2
ok 1 - (unnamed test)
1..1
ok 2 - tap test #2 # time=1.138ms
# Subtest: tap test #3
inside tape test #3
ok 1 - (unnamed test)
1..1
ok 3 - tap test #3 # time=1.069ms
1..3
# time=24.117ms
ok 1 - ./tap-test.js # time=192.82ms
1..1
# time=206.623ms
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();
});
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment