Output shows 0 tests when promise is resolved
dbowen-ibp opened this issue · 3 comments
Hello,
I have a tests directory with this single file (test.spec.js) in it.
var tape = require('blue-tape');
tape('test', function(assert) {
return Promise.resolve();
});
When I run node node_modules/.bin/tape tests/*.spec.js
here is the output I get:
TAP version 13
# test
1..0
# tests 0
# pass 0
# ok
However, when I have this as my test:
var tape = require('blue-tape');
tape('test', function(assert) {
return Promise.reject();
});
I get the following output:
TAP version 13
# test
not ok 1 (unnamed assert)
---
operator: fail
...
1..1
# tests 1
# pass 0
# fail 1
Why does a test with a resolved promise incorrectly tell me that I have 0 tests and 0 passing? But a rejected promise correctly tells me that I have 1 test and 1 failing?
Thanks!
IIRC this was done intentionally so that things like t.plan
are not affected by returned promises.
Huh. So the workaround is to use t.plan()
instead?
The resolved promise is not considered to be an assertion. Its instead considered to be an async test that simply ended.
Since the test ended without doing any assertions, the assertion count is zero.
If you add assertions, they will be counted. Nested tests will also be counted.