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

mystery fail with async test #30

Open
mixmix opened this issue Aug 9, 2022 · 2 comments
Open

mystery fail with async test #30

mixmix opened this issue Aug 9, 2022 · 2 comments

Comments

@mixmix
Copy link
Contributor

mixmix commented Aug 9, 2022

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

@tbeseda
Copy link
Member

tbeseda commented Aug 10, 2022

Yikes. Thanks for reporting and the reproduction steps.
I wonder if it's related to this bug #28
And either way I think both are related to how tap-arc handles streams.
I need to iron that out, and as mentioned previously, it has generally outgrown its single-file design and could use a refactor.

Things are a bit busy in other areas, but I'm hoping to carve out some time for this lib soon.

@mixmix
Copy link
Contributor Author

mixmix commented Aug 12, 2022

No hurry from me - I just wanted to document what little hints i found.
I tried writing a simpler test but it didn't work.

I wondered if it was timing out on the test too early? dunno

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

No branches or pull requests

2 participants