Skip to content

Instantly share code, notes, and snippets.

@farisadln
Last active March 23, 2021 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save farisadln/9b535094222d11f9124de80951993ba1 to your computer and use it in GitHub Desktop.
Save farisadln/9b535094222d11f9124de80951993ba1 to your computer and use it in GitHub Desktop.
// import modul yang di perlukan
const chai = require("chai");
const expect = require("chai").expect;
const chaiHttp = require("chai-http");
chai.use(chaiHttp);
require("dotenv").config();
const api = chai.request(process.env.URL); // response base url
module.exports = function () {
describe("Test get data from jsonplaceholder", function () {
it("Success", function (done) {
api
.get("/posts/1") // karena kita ingin mengabl data maka kita menggunaka 'get' dan "/post/1" adalah endpoint yang di tuju
.set("Content-type", "application/json")
.end(function (err, res) {
// kita dapat melakukan response assertion cirteria yang kita inginkan
expect(res.status).to.equals(200);
done();
});
});
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment