`node:test` custom reporters get `test:stdout` and `test:stderr` events before `test:dequeue`
Nessuno ha ancora preso questa issue.
- Lingua principale
- JavaScript
- Stelle
- 122k
- Fork
- 37.3k
- Merge medio
- 4g 2h
- PR unite (30g)
- 283
Descrizione
Version
v22.2.0
Platform
Linux 6a770f0f664c 6.6.26-linuxkit #1 SMP Sat Apr 27 04:13:19 UTC 2024 aarch64 GNU/Linux
Subsystem
test_runner
What steps will reproduce the bug?
Create a folder with these files:
index.test.mjs:
import { it } from "node:test";
it("test", () => {
console.log("message from the test");
});
reporter.mjs:
import util from "node:util";
export default async (source) => {
for await (const event of source) {
if (event.type === "test:stdout") {
console.log(event.type, util.inspect(event.data.message));
}
if (event.type === "test:dequeue") {
console.log(event.type, event.data.name);
}
}
};
and run
node --test --test-reporter=./reporter.mjs
which will print
test:dequeue index.test.mjs
test:stdout 'message from the test\n'
test:dequeue test
How often does it reproduce? Is there a required condition?
It always does the same
What is the expected behavior? Why is that the expected behavior?
I expected test:dequeue test to be printed before test:stdout 'message from the test\n' as the documentation states "Emitted when a test is dequeued, right before it is executed."
What do you see instead?
The test:stdout event is emitted before the test:dequeue, which makes it impossible to understand which test was running when the message was written to stdout.
Additional information
No response
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo il comando segnalato con index.test.mjs e reporter.mjs per riprodurre l’ordine degli eventi. Leggi la gestione di reporter-event di node:test test_runner e aggiungi la copertura per questo caso; il lavoro è completato quando test:dequeue è osservabile prima di test:stdout per l’output di quel test, in conformità con la semantica documentata.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- javascript, node.js
- Ambito
- testing-qa
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 52/100