-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
socket.io/eventEmitter 單元測試與回歸測試 #17
Comments
先不論 code 有沒有 bug,
我這邊寫了一個可以動的例子,參考參考 https://gist.github.com/jasperck/3ef7261ca2b9eac883928f656e35822a
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
目的
我近期在建立一個關於socket.io應用的專案(類似聊天室),最近要做單元測試和回歸測試
使用的工具
我在 windows 7 下使用 npm 安裝 node.js v6.2.1,
socket.io v1.4
unittest 套件
mocha, should
操作流程
為了做socketIo的單元測試,我做了以下操作:
describe('unittest', () => {
before('init', () => {
//init
});
it('eventEmitter listen', ()=>{
emitter.on('someEvent', (receiveObj) => {
should(receiveObj).have.property('name', 'userName');
});
});
});
});
});
遇到的問題
Microsoft Windows [版本 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
D:....event_handler>mocha competeLockTest.js
unittest: CompeteLockEventHandler
server site: event handlers
√ client site:
1 passing (116ms)
註解: 其實他甚麼都沒有檢查到!!!!!!!!!!!!!! 連client送到server site的event都沒監聽到,eventEmitter也沒聲沒息
嘗試過的解法
我嘗試過把結構改成
describe('unittest', () => {
describe('xxx', () => {
it('eventEmitter listen', (){...} )
it('server site' (){...} )
})
程式碼
下面附上我的程式碼以及我遇到的"錯誤"
程式碼
const clientIo = require('socket.io-client');
var socketURL = 'http://127.0.0.1:1337';
var serverIo = socketIo.listen(Server);
var password = '0000';
var createRoomInfo_A = {uid: 'Terrence0503',
roomName: 'Top Secrit',
pwd: password };
var createRoomInfo_B = {uid: 'Leo3355687',
roomName: 'Nice Club',
pwd: password };
var uid_A = 'Terrence0503', userA = { uid: uid_A, objCode: '0001', },
uid_B = 'Sziyu321654', userB = { uid: uid_B, objCode: '0001', };
function funcCreateRoom(client, createRoomInfo, delay) {
}
describe('unittest: Create Room', () => {
});
錯誤
Microsoft Windows [版本 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
D:...\event_handler>mocha competeLockTest.js
TestServer running at http://127.0.0.1:1337/
unittest: CompeteLockEventHandler
server site: event handlers
√ client site:
1 passing (116ms)
他至少應該要在打勾的地方出現我用should/assert測試的語句,但其實他甚麼都沒有檢查到!!!!!!!!!!!!!! 連client送到server site的event都沒監聽到,eventEmitter也沒聲沒息。
The text was updated successfully, but these errors were encountered: