Skip to content

Instantly share code, notes, and snippets.

@A
Created December 22, 2013 14:04
Show Gist options
  • Save A/8083128 to your computer and use it in GitHub Desktop.
Save A/8083128 to your computer and use it in GitHub Desktop.
var request = require('supertest');
var assert = require('assert');
// ...
var testUser = {
username: 'thisisatestuser',
email: '[email protected]',
password: 'test'
};
var otherTestUser = {
username: 'thisisatestuser',
email: '[email protected]',
password: 'test'
};
var sessionid;
var bookid;
var componentid;
describe('test', function () {
// ...
it('Login', function (done) {
request(app)
.post(routes.login)
.send(testUser)
.expect(302)
.end(function (err, res) {
// Здесь я запоминаю идентификатор сессии.
sessionid = res.headers['set-cookie'][0];
done(err);
});
});
it('Return projects list', function (done) {
request(app)
.get(routes.projects)
// А здесь я просто добавляю его к заголовку.
.set('Cookie', sessionid)
.expect(200)
.end(function (err, res) {
done(err);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment