Skip to content

Instantly share code, notes, and snippets.

@BartKrol
Last active April 24, 2017 10:38
Show Gist options
  • Save BartKrol/38c65629ab5f1815b62a5926ed070891 to your computer and use it in GitHub Desktop.
Save BartKrol/38c65629ab5f1815b62a5926ed070891 to your computer and use it in GitHub Desktop.
PoC for testing lib for express
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