Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Simple GET test with supertest
var app = require("express")();
app.get('/user', function(req, res){
res.send(200, { name: 'marcus' });
// In order to reach the app from other modules
// we need to export the express application
module.exports.getApp = app;
var request = require('supertest');
// Here we get hold of the express application
// by using the exported 'getApp'-property
var app = require("./getApp").getApp;
describe('GET /users', function(){
it('respond with json', function(done){
// the request-object is the supertest top level api
.set('Accept', 'application/json')
.expect('Content-Type', /json/)
.expect(200, done); // note that we're passing the done as parameter to the expect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment