tap harness caches the test name on a possibly shared 'conf' object #24

Closed
trentm opened this Issue Dec 5, 2011 · 0 comments

Projects

None yet

2 participants

@trentm
Contributor
trentm commented Dec 5, 2011

Code ("foo.js"):

var test = require('tap').test;
var config = {timeout: 8000}
test("one", config, function(t) {
  t.ok("one");
  t.end()
});
test("two", config, function(t) {
  t.ok("two");
  t.end();
});
test("three", config, function(t) {
  t.ok("three");
  t.end();
});

Output:

$ TAP=1 ./node_modules/.bin/tap foo.js
# three
ok 1 (unnamed assert)
# three
ok 2 (unnamed assert)
# three
ok 3 (unnamed assert)
# tests 3
# pass  3
# ok
ok 4 foo.js


1..4
# tests 4
# pass  4

# ok

Notice "# three" for each test.

One fix is to create a copy of the 'conf' object: https://gist.github.com/1435063

Alternatively, if only the 'name' is put on this.conf, then could just have a separate this.name.

@trentm trentm added a commit to trentm/node-tap that referenced this issue Dec 7, 2011
@trentm trentm Fix #24: ensure separate test cases get their own 'conf' copy 09dbad2
@isaacs isaacs closed this in 28c998a Dec 7, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment