Should tearDown be queued on process.nextTick?
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript
- Lĩnh vực
- testing
Hướng nghiên cứu
Tái hiện vấn đề với các fixture async.auto và async.parallel được nêu trong báo cáo, sau đó kiểm tra nodeunit/lib/core.js quanh wrapTest và cách xử lý teardown của nó. Xác minh thứ tự của tearDown so với các callback bất đồng bộ, đồng thời xác nhận rằng các bài kiểm thử đã hoàn thành không còn truy cập trạng thái đã được dọn dẹp trước khi tearDown hoàn tất.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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?
- Ngôn ngữ chính
- JavaScript
- Star
- 1.9k
- Fork
- 359
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của caolan/nodeunit
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 42/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
Tất cả issue của caolan/nodeunit
Issue tương tự
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 83/100
module-federation/core#5205 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
affects:v0.5.2 area:frontend audit:ui-ux-2026-10 bug priority:P2
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
berntpopp/kidney-genetics-db#326 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
task
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 83/100
TAMULib/fw-registry#550 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
-
NWCWalletService.subscribe: response is never published if the handler finishes after unsubscribe (regression in 8.1.0)Có thể đã có người làm @ajaysehwal đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100