Skip to content

mystery fail with async test #30

@mixmix

Description

@mixmix

Describe the issue

We see a test file which when run in isolation works, but fails when run with a glob script like

    "test:js": "cross-env NODE_ENV=test tape -r esm 'test/**/*.test.js' | tap-arc",

The error looks like:

test count(1) != plan(null)

The test looks like :

const test = require('tape')
const TestBot = require('./test-bot')

function setENV (env) {
  process.env.NODE_ENV = env
  // console.info('set NODE_ENV=', env)
}

// this test passes in isolation, but fails in the suite... why?
// this only happens with tap-arc T_T
// tap-spec works fine
test('init (run migrations)', t => {
  t.plan(1)

  const initialENV = process.env.NODE_ENV
  setENV('production')

  TestBot()
    .then(({ ssb }) => {
      setENV(initialENV)
      t.pass('ran migrations, started up')
      ssb.close()
    })
    .catch(err => t.error(err, 'init (run migrations) threw an error')) // should not be run
})

Inside TestBot there is some async stuff running database migrations, a setImmediate
What's strange is tap-spec doesn't hit this bug, and tape without a pretty-printer is fine.

REPO: https://gitlab.com/ahau/lib/ssb-plugins/ssb-ahau
file : tests/init.test.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions