Skip to content

Instantly share code, notes, and snippets.

@seansullivan
Last active August 29, 2015 13:57
Show Gist options
  • Save seansullivan/9924729 to your computer and use it in GitHub Desktop.
Save seansullivan/9924729 to your computer and use it in GitHub Desktop.
Setting the locals for an Express render() as the response body for testing purposes
/*
// Route defined as:
app.get('/test/login', function (req, res) {
res.render('login/login', {something: 'here'});
});
*/
var localsAsResponseEngine = function (pathName, locals, cb) {
delete locals._locals;
delete locals.settings;
cb(null, locals);
};
describe("Auth Server Endpoints", function() {
var app = require('../app');
describe('Base Views', function() {
it('Should respond with login form', function (done) {
app.engine('html', localsAsResponseEngine);
request(app)
.get('/test/login')
.expect(200)
.end(function (req, res) {
var context = res.body;
expect(context).to.have.property('something');
expect(context.something).to.equal('here');
done();
});
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment