????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
????????
?????????????????????????????????????????????????????