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

When using spec reporter, doesn't bail if test plan is exceeded in a promise callback #348

Closed
novemberborn opened this issue Feb 10, 2017 · 1 comment

Comments

@novemberborn
Copy link
Contributor

Using tap@10.1.0.

With test.js:

const test = require('tap').test

test('foo', t => {
  t.plan(1)

  return Promise.resolve()
    .then(() => {
      t.ok(true)
      t.ok(true)
      t.end()
    })
})

test('bar', t => {
  t.ok(true)
  t.end()
})

Output:

$(npm bin)/tap --bail -R spec test.js

test.js
  foo
    ✓ expect truthy value

  bar
    ✓ expect truthy value

  1) test count exceeds plan
  2) test count !== plan

  2 passing (241ms)
  2 failing

  1) test.js test count exceeds plan:
     Error: test count exceeds plan
      at Promise.resolve.then (test.js:9:9)

  2) test.js test count !== plan:

      test count !== plan
      + expected - actual

      -3
      +1



  3) test count !== plan

I can't tell in which test the plan was exceeded. The error is printed once all tests have completed.

It's fine when using the TAP reporter:

$(npm bin)/tap --bail test.js
test.js ............................................... 2/3
  not ok test count exceeds plan
    stack: |
      Promise.resolve.then (test.js:9:9)
    at:
      line: 9
      column: 9
      file: test.js
      function: Promise.resolve.then
    test: foo
    plan: 1
    source: |
      t.ok(true)

Bail out! # test count exceeds plan
total ................................................. 2/4


  2 passing (239ms)
  2 failing

If I modify test.js to:

const test = require('tap').test

test('foo', t => {
  t.plan(1)
  t.ok(true)
  t.ok(true)
  t.end()
})

test('bar', t => {
  t.ok(true)
  t.end()
})

And rerun with the spec reporter, the output is as expected:

$(npm bin)/tap --bail -R spec test.js

test.js
  foo
    ✓ expect truthy value

  1) test count exceeds plan
  2) test count !== plan

  1 passing (253ms)
  2 failing

  1) test.js test count exceeds plan:
     Error: test count exceeds plan
      at Test.t (test.js:6:5)
      at Object.<anonymous> (test.js:3:1)

  2) test.js test count !== plan:

      test count !== plan
      + expected - actual

      -2
      +1



  3) test count !== plan
@isaacs
Copy link
Member

isaacs commented May 23, 2019

This is no longer a bug on the latest release.

@isaacs isaacs closed this as completed May 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants