Ava: stream.clearLine is not a function

Created on 1 Jun 2018  路  7Comments  路  Source: avajs/ava

When upgrading to the beta5 I started hitting this error. It looks like it's erroring out in an Ora dep but may be related to the commit _(linked in the previous sentence)_.

I'm on MacOS 10.13.4 using iTerm 3 with oh-my-zsh.

bug help wanted

Most helpful comment

Ah! It's failing when called through your test suite, right?

AVA must be assuming it has a TTY stream, while it doesn't. It's doing that check on oras behalf. We'll need to look at that detection when AVA is invoked through execa like you do here.

A workaround is to specify CI=1 as an environment variable, which supersedes all other TTY detection, and thus disables the spinner (which is rendered through ora).

All 7 comments

Could you share an AVA project in which this occurs? Or is it any plain import test from 'ava'; test('test', t => t.pass())?

Yep!

It's a basic scenario test _(all my AVA scenarios regardless of test will fail with beta5 though)_.
For example this one.

Ah! It's failing when called through your test suite, right?

AVA must be assuming it has a TTY stream, while it doesn't. It's doing that check on oras behalf. We'll need to look at that detection when AVA is invoked through execa like you do here.

A workaround is to specify CI=1 as an environment variable, which supersedes all other TTY detection, and thus disables the spinner (which is rendered through ora).

Thanks, the CI=1 workaround does work around it :)

Same with beta.5.1 on Windows 10 x64:

- W:\github\postcss-grid-kiss\node_modules\ora\index.js:83
            this.stream.clearLine();
                        ^

TypeError: this.stream.clearLine is not a function
    at Ora.clear (W:\github\postcss-grid-kiss\node_modules\ora\index.js:83:16)
    at Ora.render (W:\github\postcss-grid-kiss\node_modules\ora\index.js:92:8)
    at ontimeout (timers.js:427:11)
    at tryOnTimeout (timers.js:289:5)
    at listOnTimeout (timers.js:252:5)
    at Timer.processTimers (timers.js:212:10)
npm ERR! Test failed.  See above for more details.

@sylvainpolletvillard for now you can use --verbose (or the corresponding verbose config option) as a workaround.

The problem seems to be with this line:

https://github.com/avajs/ava/blob/a4f741cfb7b32c92a2031e6d11bfdab71acc1a61/lib/reporters/mini.js#L84

This disables ora's TTY detection, which is intentional. However it doesn't look like AVA is doing any detection on its own! This is an oversight on my part; I was planning further changes so may have forgotten to adjust this.

Changing that line to enabled: options.reportStream.isTTY should fix the issue.

If anybody wants to raise a PR for that change that'd be appreciated. I've been traveling recently and have more travel coming up soon.

Actually the mini reporter shouldn't be used if stdout is not a TTY.

Was this page helpful?
0 / 5 - 0 ratings