Last active
November 13, 2018 21:32
-
-
Save evanshortiss/ea9e18f5e0f75bf52a4ea68fdd2ae7eb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const supertest = require('supertest') | |
const express = require('express') | |
const router = require('lib/routes/some-router') | |
describe('#some-router tests', () => { | |
// temp express app. allows to tests routes in isolation from broader application | |
const app = express() | |
// app.use(router()) or whatever way works for your structure | |
app.use('/stuff', router) | |
it('should return a 400 error', (done) => { | |
const request = supertest(app) | |
const itemId = 10 | |
request.get(`/stuff/items/${itemId}`) | |
.expect('Content-Type', /json/) | |
.expect(400) | |
.end(function(err, res) { | |
if (err) { | |
done(err) | |
} | |
// more assertions? | |
done() | |
}); | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment