Nodejs???????С??
???????????? ???????[ 2015/7/10 10:05:19 ] ?????????????????? ???????
????2. ???????????????
?????????????????????????????????????仰???????д??????????????????????д?????????????????????????????ν???????????????
???????????
describe('sign up'?? function() {
it('should not sign up an user when loginname is empty'?? function(done) {
request.post('/signup')
.send({
loginname: ''??
password: password
})
.expect(200?? function(err?? res) {
should.not.exist(err);
res.text.should.containEql('????????????????');
done();
});
});
it('should not sign up an user when it is exist'?? function(done) {
request.post('/signup')
.send({
loginname: loginname??
password: password
})
.expect(200?? function(err?? res) {
should.not.exist(err);
res.text.should.containEql('??????????');
done();
});
});
});
??????д????????????????????????????????????????????????д??????μ???????????????????????????????????????????????????????"???????"??
????3. ???cookie??session????????
??????web?????У?Cookie??????????????á????HTTP??????????????????cookie??????????????????????????????????cookie??????????
??????????????????cookie??sessionЭ???????????????????????????????????????????????????????????????????????е?id????????????????????????????????????????????????????????????????????
???????????????????????д?????????????????????????????????????鷳?????????????????????????????????????cookie??session???
?????????express???м?????????????
?????????????????supertest????HTTP???????????????????????????cookie??
????set('Cookie'?? cookieValue)
???????????д???????????м????
????app.use(function(req?? res?? next) {
????if (config.debug && req.cookies['mock_user']) {
????var mockUser = JSON.parse(req.cookies['mock_user']);
????req.session.user = new UserModel(mockUser);
????return next();
????}
????next();
????});
????????????ж????????????????????config???????????????????????????true??????ж??????м??mock_user??cookie??????????????????session?????user???????????????????????????????????
???????????????????????????μ??mock_user??cookie?????????÷??????test???????support/support.js???????????
????4. ?????????
???????????????????????????棬?????????????????????????????????????????mocha????к??istanbul?????????????windows????д??????????дMakefile??????????????????Windows???????Windows????istanbul???????????????????http://stackoverflow.com/questions/27084392/code-coverage-for-mocha-in-windows-7
?????????Windows???е????????????????????У?
????*./node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha
????????
?????????????????????????????????????????????????????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11