nodejs / nodejs/node

test runner (--test, node:test) subtest test context lack `.skip`, `.only` and `.todo` functions

Aperta
#50,665 6 commenti 5 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

confirmed-bug test_runner
Lingua principale
JavaScript
Stelle
122k
Fork
37.3k
Merge medio
4g 2h
PR unite (30g)
283

Descrizione

Version

20.7.0

Platform

Linux void-desktop 6.5.9_1 #1 SMP PREEMPT_DYNAMIC Thu Oct 26 12:11:50 UTC 2023 x86_64 GNU/Linux

Subsystem

No response

What steps will reproduce the bug?
const test = require('node:test');

test('Parent', t => {
	t.test.only('Child only', () => {});
	t.test.skip('Child skip', () => {});
	t.test.todo('Child todo', () => {});
});

Run with node --test <file> (same result without the --test flag)

How often does it reproduce? Is there a required condition?

Consistently

What is the expected behavior? Why is that the expected behavior?

All functions work as described here: https://nodejs.org/docs/latest-v20.x/api/test.html#subtests

This method behaves identically to the top level test() function. The following example demonstrates the creation of a top level test with two subtests.

What do you see instead?
TypeError [Error]: t.test.todo is not a function
TypeError [Error]: t.test.skip is not a function
TypeError [Error]: t.test.only is not a function
Additional information

These functions work for top-level test, they don't work for nested tests.
Maybe it doesn't make sense to expose those functions for subtests (use just describe - maybe it's enough), but in that case the documentation is misleading

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dal punto di ingresso dell'API dei sottotest di node:test e riproduci il test annidato fornito con node --test o senza il flag. Confronta il comportamento documentato di t.test.only, t.test.skip e t.test.todo con i TypeErrors osservati; il lavoro è completo quando il comportamento dell'API annidata e la documentazione concordano sul comportamento previsto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
javascript, node.js
Ambito
testing
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
38/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.