Skip to content

Instantly share code, notes, and snippets.

@luqmanoop
Last active November 22, 2018 20:25
Show Gist options
  • Save luqmanoop/acc8d059230910149b6302c9cd9841fb to your computer and use it in GitHub Desktop.
Save luqmanoop/acc8d059230910149b6302c9cd9841fb to your computer and use it in GitHub Desktop.
A simple TDD case for a `/cats` endpoint
import chai, { expect } from "chai";
import chaiHttp from "chai-http";
import server from "../server";
chai.use(chaiHttp);
const ENDPOINT = "/api/v1/cats";
let request = null;
describe("/api/v1/cats", () => {
before(() => {
request = chai.request(server).keepOpen();
});
after(() => request.close());
describe("GET /", () => {
it("should respond with an array of cats", done => {
request.get(ENDPOINT).then(res => {
expect(res.body).to.be.an("array").that.is.not.empty;
done();
});
});
});
});
@akhilome
Copy link

Superb one, @codeshifu.

Thanks for providing clarity with the comment, too. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment