Last active
April 24, 2017 10:38
-
-
Save BartKrol/38c65629ab5f1815b62a5926ed070891 to your computer and use it in GitHub Desktop.
PoC for testing lib for express
This file contains 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 request = require('superexpress') | |
const { getResources } = require('./controllers/resourses') | |
const expectedData = [...] | |
// Testing code with Chai+Mocha | |
describe('My test', () => { | |
it('should return resources' () => { | |
return request(getResources) | |
.query({ name: 'some-name', conditon: 'some-condition' }) | |
.expect(200, expectedData) | |
}) | |
}) | |
// Testing with Ava | |
const test = require('ava') | |
test('returns correct resources', t => { | |
return request(getResources) | |
.query({ name: 'some-name', conditon: 'some-condition' }) | |
.then(res => { | |
t.deepEqual(res.body, expectedData) | |
t.is(res.status, 200) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment