Ava: "^1.0.0-beta.8",
I'm trying a simple wait function:
function wait (sec) {
const ms = (sec) ? sec * 1000 : 1000
return new Promise((resolve, reject) => {
return setTimeout(resolve, ms)
})
}
test('test wait', async t => {
let a
console.log('_0')
a = await wait()
console.log('_1')
a = await wait(2)
console.log('_2')
t.pass()
})
It will pass but not console.log anything after _0
There is a $60.00 open bounty on this issue. Add more on Issuehunt.
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on Issuehunt to raise funds.
Works for me:
❯ npx ava -v test.js
_0
_1
_2
✔ test wait (3s)
1 test passed
Note that AVA writes any console calls to stderr, not stdout.
What OS, shell and terminal app are you using?
(I'm closing this issue for housekeeping purposes, but let's keep the conversation going.)
macOS with iTerm2 and fish shell
Hmm. I'm the same, except for Zsh. I don't know why this would be happening, sorry.
@mesqueeb it would be nice if you could create a repository that will reproduce the issue
@novemberborn @havenchyk Trying to replicate this, I had moved it to a separate test file and it worked.
But when in the same test file as other tests this breaks.
After some tinkering I found it that AVA replaces my console logs with the name of the other test instead of what I wrote in the console log.
Look at this screenshot below: top is a test file with only wait, the second is a test file with wait and another test. I'm not console.logging anything in the other test, but it starts to log the other test's name!

It's reproducable if you clone this:
https://github.com/mesqueeb/vuex-easy-firestore/tree/rewrite-tests
notice tree/rewrite-tests
Then just yarn and yarn test ./test/mutations.js
Comment out the SET_PATHVARS test and it will work.
Aha!
Here's a minimal reproduction:
import test from 'ava'
import delay from 'delay'
test('slow log', async t => {
console.log('_0')
await delay(1000)
console.log('_1')
await delay(2000)
console.log('_2')
t.pass()
})
test('other test', t => {
t.pass()
})
With the default (mini) reporter:
$ npx ava test.js
⠧ _0
⠙ other test
⠧ other test
2 tests passed
With the verbose reporter:
$ npx ava test.js -v
_0
✔ other test
_1
_2
✔ slow log (3s)
2 tests passed
The mini reporter gets tripped up by the console output. I think that may be a regression cause I distinctly remember testing for this. See https://github.com/avajs/ava/blob/ff09749e936fb005155fff715b0325a0b02a36c1/lib/reporters/mini.js#L197:L216.
Thanks for persisting, @mesqueeb 😄
Just ran into this, thanks for the --verbose tip workaround!
@issuehunt has funded $60.00 to this issue.
Both due to the age of this issue, and the state of our reporters, I've decided to roll this into #2501.
Most helpful comment
Just ran into this, thanks for the
--verbosetip workaround!