Testing response from a call back failure.
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 35/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- javascript
- 領域
- testing-qa
研究方向
先從所示的 stripReady 測試和 nodeunit 的非同步測試生命週期開始,然後使用 issue 中描述的硬體設定執行測試。當觀察到 ready 事件且其 assertion 在 nodeunit 結束前完成,並且該行為可重現或已獲得解釋時,即表示完成。
由索引模型根據 Issue 內容生成。
描述
So I have some code that requires waiting for a call back and testing the response of it.
For some reason the callback never managed to get called. I've stepped through the code with the debugger but the nodeunit process finishes (with unfinished tests) before the callback can actually fire. I have no doubt I am doing something wrong but no idea what.
This is the test code I'm using:
exports["Strip - Firmata"] = {
setUp: function(done){
this.board = newBoard();
done();
},
tearDown: function(done) {
Board.purge();
restore(this);
done();
},
stripReady: function(test) {
test.expect(1);
var strip = new pixel.Strip({
data: 6,
length: 8,
board: this.board,
controller: "FIRMATA",
});
strip.on("ready", function() {
console.log("strip ready");
test.ok(true);
test.done();
});
},
}
For context: The stripReady test needs to test that a particular event is being emitted by the strip object once it's good to go (this is talking to some hardware behind the scenes). Down the line I'll want to test the appropriate error events as well.
When I trace this with the debugger, the strip constructor gets called, the handler gets bound but right at the moment the handler is bound nodeunit then exits.
As such it doesn't get a chance to drop into the ready handler shown above. I can trace to the point where it emits the message on the Strip side but that event handler never gets called.
So the question is how do I get nodeunit to hang around long enough to get the response back?
FYI the strip constructor is correct and it working properly with the hardware.
- 主要語言
- JavaScript
- 星號
- 1.9k
- 分支
- 359
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
caolan/nodeunit 的其他 Issue
-
難度 4/5 3-5 天 新手友好度 25/100
-
難度 3/5 1-2 天 新手友好度 35/100
-
難度 2/5 1-3 小時 新手友好度 42/100
-
難度 3/5 1-2 天 新手友好度 35/100
-
難度 5/5 一週以上 新手友好度 20/100
相似的 Issue
-
task
難度 1/5 1 小時以內 新手友好度 83/100
TAMULib/fw-registry#550 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 79/100
-
NWCWalletService.subscribe: response is never published if the handler finishes after unsubscribe (regression in 8.1.0)可能已有人在做 @ajaysehwal 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 83/100
-
難度 1/5 1 小時以內 新手友好度 88/100
bigskysoftware/htmx#4151 ·
維護者通常 4 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100