Skip to content

Instantly share code, notes, and snippets.

@kianaditya
Last active July 1, 2020 11:10
Show Gist options
  • Save kianaditya/8bae97b23716601049808e1e9a7269f5 to your computer and use it in GitHub Desktop.
Save kianaditya/8bae97b23716601049808e1e9a7269f5 to your computer and use it in GitHub Desktop.
const request = require('supertest')
const app = require('../src/app')
const expect = require('chai').expect
describe('GET /posts endpoint', () => {
it('GET /posts endpoint successfully returns response', () => {
return request(app)
.get('/posts')
.then((response) => {
expect(response.statusCode).to.equal(200)
expect(response.body)
.to.be.an.instanceof(Array)
.and.to.have.length(4)
.and.to.have.property(0)
.that.includes.all.keys(['id', 'title', 'content', 'Author'])
.and.to.have.nested.property('Author')
.to.be.an.instanceof(Object)
.that.includes.all.keys(['firstName', 'lastName'])
})
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment