Skip to content

WIP: Consolidate mini and verbose reporters #1776

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

Closed
wants to merge 1 commit into from

Conversation

novemberborn
Copy link
Member

Calling this a work in progress is an overstatement, but I wanted to at least communicate what I'm trying to do.

#1722 did some major refactoring of the reporters. Here, I'd like to consolidate the mini and verbose reporters into a single, default reporter.

  • When in a TTY (outside of a CI environment), shows a spinner with the status of the latest test, and the counts of various test states
  • Only when a test file exits, results for that file are printed
    • In the default mode (without --verbose) only failures are shown. t.log() isn't shown for passing tests
    • In verbose mode the results of all tests are shown
  • CI no longer defaults to --verbose. It only did that to disable the spinner, but the reporter now detects whether a spinner is supported.

Fixes #653. Fixes #1337.

if (str) {
this.write(indentString(str, 2) + os.EOL);
} else {
this.write(os.EOL);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to use os.EOL. Windows also supports \n for console output. Even console.log in Node.js uses \n: https://github.com/nodejs/node/blob/34bd9f318a164d6b2ee949793146b85b3e152d5f/lib/console.js#L141-L148

return;
}

const str = chunk.toString('utf8');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using .toString('utf8') on chunks is an anti-pattern, as the chunk might be split on a Unicode code point, resulting in an invalid character. The correct way is to do `setEncoding('utf8') on the stream. That is also more efficient.

}
}

consumeStateChange(evt) { // eslint-disable-line complexity
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use a more descriptive name than evt?

// we multiplex stdout and stderr into a single stream. However as
// long as stdStream is different from reportStream users can read
// their original output by redirecting the streams.
if (evt.chunk[evt.chunk.length - 1] !== 0x0A) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make 0x0A a local constant, so it's clear what it is?

}

_writeWithSpinner(chunk) {
if (!this.spinner || !this.spinner.id) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With latest Ora, you can check this.spinner.isSpinning instead of this.spinner.id: sindresorhus/ora@3df8d0d

@novemberborn novemberborn mentioned this pull request Jun 28, 2018
@novemberborn
Copy link
Member Author

It may be worth considering not printing non-AVA output unless --verbose is set. #1849 (comment)

@sindresorhus
Copy link
Member

It may be worth considering not printing non-AVA output unless --verbose is set. #1849 (comment)

👍 Seems fine. We have t.log() now for stuff that should actually be shown.

@novemberborn
Copy link
Member Author

Closing for now.

@novemberborn novemberborn deleted the default-reporter branch August 18, 2019 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Should we move pass / fail count to the end of the output? mini reporter should surface failures faster.
2 participants