Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failure due to plan != count causes all other tests to fail as 'exited without ending' #550

Open
7v0lk0v opened this issue Feb 25, 2021 · 3 comments

Comments

@7v0lk0v
Copy link

7v0lk0v commented Feb 25, 2021

Howdy, this is a peculiar one:

test = require('tape');
test('failed plan', function(t){
  t.plan(1);
});

test('not even called', function(t){
  t.comment('------------ not called');
  t.plan(1);
  t.pass();
  // t.end();
});

Expected the 2nd test to pass but it doesn't even get called. Whether the 2nd test uses t.plan or t.end makes no difference. Additionally, all tests in other files also fail in the same fashion when run as tape test/*.js (the above is the minimal necessary to reproduce the issue).

Output below:

TAP version 13
# failed plan
not ok 1 plan != count
  ---
    operator: fail
    expected: 1
    actual:   0
    at: process.<anonymous> (/home/pechkin/data/kb/node_modules/tape/index.js:85:19)
    stack: |-
      Error: plan != count
          at Test.assert [as _assert] (/home/pechkin/data/kb/node_modules/tape/lib/test.js:310:54)
          at Test.bound [as _assert] (/home/pechkin/data/kb/node_modules/tape/lib/test.js:91:32)
          at Test.fail (/home/pechkin/data/kb/node_modules/tape/lib/test.js:404:10)
          at Test.bound [as fail] (/home/pechkin/data/kb/node_modules/tape/lib/test.js:91:32)
          at Test._exit (/home/pechkin/data/kb/node_modules/tape/lib/test.js:261:14)
          at Test.bound [as _exit] (/home/pechkin/data/kb/node_modules/tape/lib/test.js:91:32)
          at process.<anonymous> (/home/pechkin/data/kb/node_modules/tape/index.js:85:19)
          at process.emit (node:events:376:20)
  ...
not ok 2 test exited without ending: not even called
  ---
    operator: fail
    at: process.<anonymous> (/home/pechkin/data/kb/node_modules/tape/index.js:85:19)
    stack: |-
      Error: test exited without ending: not even called
          at Test.assert [as _assert] (/home/pechkin/data/kb/node_modules/tape/lib/test.js:310:54)
          at Test.bound [as _assert] (/home/pechkin/data/kb/node_modules/tape/lib/test.js:91:32)
          at Test.fail (/home/pechkin/data/kb/node_modules/tape/lib/test.js:404:10)
          at Test.bound [as fail] (/home/pechkin/data/kb/node_modules/tape/lib/test.js:91:32)
          at Test._exit (/home/pechkin/data/kb/node_modules/tape/lib/test.js:267:14)
          at Test.bound [as _exit] (/home/pechkin/data/kb/node_modules/tape/lib/test.js:91:32)
          at process.<anonymous> (/home/pechkin/data/kb/node_modules/tape/index.js:85:19)
          at process.emit (node:events:376:20)
  ...

1..2
# tests 2
# pass  0
# fail  2

The event emitted at the bottom of the stack is exit from the async trampoline.

Reproduced here.
Note that the codepen doesn't capture the same output as when running the same code locally.

Tested against tape v5.1.0 and v5.2.0.

@ljharb
Copy link
Collaborator

ljharb commented Feb 25, 2021

I assume this happens the same in tape v4 - I've noticed this many times in the past and it didn't register as an inherent problem, but it's reasonable to expect that the second test functions normally as long as the first test doesn't terminate the process.

@Raynos
Copy link
Collaborator

Raynos commented Feb 25, 2021

I've also noticed this many times that when tape fails sometimes it fails more loudly then other times.

I always ignore the noise and fix the root cause without thinking of removing the noise.

@7v0lk0v
Copy link
Author

7v0lk0v commented Feb 25, 2021

but it's reasonable to expect that the second test functions normally as long as the first test doesn't terminate the process.

Yep, I should've made that a bit clearer I guess - I have lots of tests that pass but having added a new test that fails the plan causes all of my passing tests to 'fail' as well; I say 'fail' because they're not actually executed but are reported as having failed.

I ignored it for some time as well but I'm at a point where the only way to fix the failing test is to fix a few other ones first which is made very difficult - the only way out is to t.skip every test that causes this issue, then unskip them, round and round.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants