Should tearDown be queued on process.nextTick?
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 25/100
- Tipo de issue
- Bug
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Stack de tecnologia
- javascript
- Domínio
- testing
Direção de pesquisa
Reproduza o problema com os fixtures de async.auto e async.parallel mostrados no relatório e, em seguida, inspecione nodeunit/lib/core.js em torno de wrapTest e do tratamento de teardown. Verifique a ordem de tearDown em relação aos callbacks assíncronos e confirme que os testes concluídos não acessam mais o estado limpo antes que tearDown termine.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
I've encountered an issue that's reproducible with async.parallel/auto and nodeunit.
var async = require('async');
var str;
exports.setUp = function(cb){
console.log('setup');
str = "This is a test";
cb();
}
exports.tearDown = function(cb){
//process.nextTick(function(){
console.log('teardown');
str = undefined;
cb();
//});
}
exports["testA"] = function(test){
async.auto({
test1:function(cb, results){
console.log('test1');
cb(new Error("test"));
},
test2:function(cb, results){
console.log('test2');
console.log(str, str.length);
cb();
}
}, function(err, results){
if(err) console.error(err);
test.done();
});
}
exports["testB"] = function(test){
async.parallel({
test1:function(cb, results){
console.log('test1');
cb(new Error("test"));
},
test2:function(cb, results){
console.log('test2');
console.log(str, str.length);
cb();
}
}, function(err, results){
if(err) console.error(err);
test.done();
});
}
This produces the output:
setup
test1
[Error: test]
teardown
test2
teardown
✖ testATypeError: Cannot read property 'length' of undefined
at Array.exports.testA.async.auto.test2 as 0
at async.auto (/Users/davefenster/node_modules/async/lib/async.js:406:38)
at Array.forEach (native)
at _forEach (/Users/davefenster/node_modules/async/lib/async.js:26:24)
at Object.async.auto (/Users/davefenster/node_modules/async/lib/async.js:382:9)
at Object.exports.testA (/Users/davefenster/temp/testnodeunitbug/test.js:19:8)
at wrapTest (/Users/davefenster/node_modules/nodeunit/lib/core.js:231:20)
at _asyncMap (/Users/davefenster/node_modules/nodeunit/deps/async.js:163:13)
at async.forEachSeries.iterate (/Users/davefenster/node_modules/nodeunit/deps/async.js:126:25)
at _asyncMap (/Users/davefenster/node_modules/nodeunit/deps/async.js:160:17)setup
test1
[Error: test]
teardown
test2
teardown
✖ testATypeError: Cannot read property 'length' of undefined
at Array.exports.testA.async.auto.test2 as 0
at async.auto (/Users/davefenster/node_modules/async/lib/async.js:406:38)
at Array.forEach (native)
at _forEach (/Users/davefenster/node_modules/async/lib/async.js:26:24)
at Object.async.auto (/Users/davefenster/node_modules/async/lib/async.js:382:9)
at Object.exports.testA (/Users/davefenster/temp/testnodeunitbug/test.js:19:8)
at wrapTest (/Users/davefenster/node_modules/nodeunit/lib/core.js:231:20)
at _asyncMap (/Users/davefenster/node_modules/nodeunit/deps/async.js:163:13)
at async.forEachSeries.iterate (/Users/davefenster/node_modules/nodeunit/deps/async.js:126:25)
at _asyncMap (/Users/davefenster/node_modules/nodeunit/deps/async.js:160:17)FAILURES: 2/2 assertions failed (12ms)
FAILURES: Undone tests (or their setups/teardowns):
- testB
To fix this, make sure all tests call test.done()
The error manifests itself because tearDown runs before all the async.auto and async.parallel functions have executed. Ideally, what I'd want is the tearDown to run only after async.auto/parallel are complete.
To make the tests pass, uncomment the process.nextTick line in the tearDown function.
Should nodeunit be putting tearDown on the nextTick queue all the time?
- Linguagem predominante
- JavaScript
- Estrelas
- 1.9k
- Forks
- 359
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de caolan/nodeunit
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 25/100
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 42/100
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
-
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 20/100
Todas as issues de caolan/nodeunit
Issues semelhantes
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 83/100
awesome-dsh-plugin/awesome-dsh-plugin#8715 ·
Mantenedores costumam responder em até 1 dia
-
[BUG]: Document embedding fails with "Cannot have chunkOverlap >= chunkSize" after switching to an embedder with a smaller max chunk lengthTalvez já em andamento @RaphaelFakhri assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 78/100
Mintplex-Labs/anything-llm#6810 ·
Mantenedores costumam responder em até 1 dia
-
needs-triage Technical TODO
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 2 dias
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
AOSSIE-Org/BabyNest#268 ·
Mantenedores costumam responder em até 1 dia
-
bug needs-triage
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Mantenedores costumam responder em até 1 dia