Last active
October 5, 2020 09:58
-
-
Save velotiotech/a26c12bd838ffa3f71cc0adba0b1aa94 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
describe(“Testing API Endpoints Using Cypress”, () => { | |
it(“Test GET Request”, () => { | |
cy.request(“http://localhost:3000/api/posts/1”) | |
.then((response) => { | |
expect(response.body).to.have.property('code', 200); | |
}) | |
}) | |
it(“Test POST Request”, () => { | |
cy.request({ | |
method: ‘POST’, | |
url: ‘http://localhost:3000/api/posts’, | |
body: { | |
“id” : 2, | |
“title”:“Automation” | |
} | |
}).then((response) => { | |
expect(response.body).has.property(“title”,“Automation”); | |
}) | |
}) | |
it(“Test PUT Request”, () => { | |
cy.request({ | |
method: ‘PUT’, | |
url: ‘http://localhost:3000/api/posts/2’, | |
body: { | |
“id”: 2, | |
“title” : “Test Automation” | |
} | |
}).then((response) => { | |
expect(response.body).has.property(“title”,“ Test Automation”); | |
}) | |
}) | |
it(“Test DELETE Request”, () => { | |
cy.request({ | |
method : ‘DELETE’, | |
url: ‘http://localhost:3000/api/post/2’ | |
}).then((response) => { | |
expect(response.body).to.be.empty; | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment