caolan / caolan/nodeunit

Run object instead of runFiles?

Aperta
#105 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
JavaScript
Stelle
1.9k
Fork
359
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

In nodeunit, whenever you call

nodeunit.reporters["default"].run(["a","b"]);

it will always, eventually, require("a") as a test and run it, then require("b") and then run it.

What if you want to load files on your own, or even define tests in memory, never saving to a file? As an example, I could see loading a file, doing some manipulation, and only then passing it through to nodeunit.

In this scenario, the two run() calls below would be equivalent:

var a = require("a");
nodeunit.reporters["default"].run(["a"]);
nodeunit.reporters["default"].runModule(a);

But the second option gives me the ability to do:

var a = require("a");
a.doSomeMod();
nodeunit.reporters["default"].runModule(a);

Even better, you don't need runModule. All you need is for run() to check each option in the array; if it is a string, require() it as a file, else just use it as is.

Whole change set could probably be done in nodeunit.js ll 61-81.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Inizia in nodeunit.js intorno alle righe 61–81 e analizza come il metodo run del reporter predefinito gestisce il proprio array di input e richiede i file di test. Confronta i casi richiesti dei moduli basati su file e in memoria, quindi verifica che entrambe le forme vengano eseguite correttamente e che il comportamento esistente rimanga invariato.

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

Valutazione

Stack tecnologico
javascript, node.js
Ambito
backend, testing-qa
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 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.