`styleText()`: isTTY check fails with `--test`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- JavaScript
- Sterne
- 122k
- Forks
- 37.3k
- Ø Merge
- 4 T. 2 Std.
- Gemergte PRs (30 T.)
- 283
Beschreibung
Version
v22.13.1
Platform
Linux 6.8.0-57-generic #59~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Mar 19 17:07:41 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
Subsystem
Ubuntu 22.04.5 LTS
What steps will reproduce the bug?
-
Create
index.mjs:import { Writable } from "node:stream"; import { styleText } from "node:util"; const streamTTY = new class extends Writable { isTTY = true; }; const streamNoTTY = new class extends Writable { isTTY = false; }; console.log(styleText("bgYellow", "TTY", { stream: streamTTY })); console.log(styleText("bgYellow", "No TTY", { stream: streamNoTTY })); -
Run
node index.mjs -
Run
node --test index.mjs
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
The text No TTY isn't stylized with --test.
-
node index.mjs^[[43mTTY^[[49m No TTY -
node --test index.mjs^[[43mTTY^[[49m No TTY ✔ index.mjs (27.022452ms) ...
What do you see instead?
The text No TTY is stylized with --test.
-
node index.mjs^[[43mTTY^[[49m No TTY -
node --test index.mjs^[[43mTTY^[[49m ^[[43mNo TTY^[[49m ✔ index.mjs (27.022452ms) ...
Additional information
With the --test option, the styleText() function doesn't check whether the stream is TTY.
With the command line: node --test index.mjs > out.txt, the file contains the correct style:
TAP version 13
# ^[[43mTTY^[[49m
# No TTY
# Subtest: index.mjs
ok 1 - index.mjs
---
duration_ms: 25.169793
...
1..1
# tests 1
# suites 0
# pass 1
# fail 0
# cancelled 0
# skipped 0
# todo 0
# duration_ms 30.191704
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der Reproduktion in index.mjs und führe sie sowohl mit node index.mjs als auch mit node --test index.mjs aus, wobei du die TTY- und Non-TTY-Ausgabe vergleichst. Verfolge die Behandlung des bereitgestellten Streams durch styleText(), während der Test Runner aktiv ist. Erledigt ist die Aufgabe, wenn der Non-TTY-Stream unter --test unformatiert bleibt, während die TTY-Formatierung und die umgeleitete Ausgabe ihr aktuelles Verhalten beibehalten.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- javascript, node.js
- Bereich
- testing-qa
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 62/100