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

CLI: Limit colors in TAP reporter to test names #1801

Merged
merged 1 commit into from
Oct 10, 2024

Conversation

Krinkle
Copy link
Member

@Krinkle Krinkle commented Sep 29, 2024

Don't apply colors to the "ok 1" and "not ok 1" prefix. This has the benefit of making the test names easier to visually extract for developers.

It also increases compatibility with the popular tap-parser package which doesn't parse TAP lines correctly otherwise, since blocks like "not ok" must start on a new line, and with the color code in front, they are technically either a continuation of the previous block, or an ignored "Anything" line between two blocks.

This hasn't been a problem in practice, since, if you pipe output from QUnit or TapReporter to a different process that uses tap-parser, colors are naturally disabled. But, if you get the console output from a browser process, the colors will be applied. I caught this while working on QTap (https://github.com/qunitjs/qtap).

https://github.com/tapjs/tapjs/tree/ccfea67fec/src/parser

https://testanything.org/tap-version-13-specification.html

Before After
Pass
Skip
Failure

@Krinkle Krinkle requested a review from mgol September 29, 2024 18:31
@Krinkle Krinkle added this to the 3.0 release milestone Sep 29, 2024
Copy link
Member

@mgol mgol left a comment

Choose a reason for hiding this comment

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

One question / suggestion, LGTM overall. The arguments seem sensible and I have no problems with the visual changes.

src/core/reporters/TapReporter.js Outdated Show resolved Hide resolved
Don't apply colors to the "ok 1" and "not ok 1" prefix. This has
the benefit of making the test names easier to visually extract
for developers.

It also increases compatibility with the popular `tap-parser`
package which doesn't parse TAP lines correctly otherwise, since
blocks like "not ok" must start on a new line, and with the color
code in front, they are technically either a continuation of the
previous block, or an ignored "Anything" line between two blocks.

https://github.com/tapjs/tapjs/tree/ccfea67fec/src/parser

https://testanything.org/tap-version-13-specification.html
@Krinkle Krinkle merged commit a006064 into qunitjs:main Oct 10, 2024
10 checks passed
@Krinkle Krinkle deleted the tap-compliant-colors branch October 10, 2024 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants