Last active
March 23, 2021 14:04
-
-
Save farisadln/9b535094222d11f9124de80951993ba1 to your computer and use it in GitHub Desktop.
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
// 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