Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
hasoloan7 committed Jun 24, 2024
2 parents e83cb9d + 97f4ba9 commit cf05cbf
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Automated Testing of the API Application KasirAja

## Requirements

- Node Js v21.7.1
- Visual Studio Code
- Cypress 13.10.0

## How to Start

- Create a Project Directory and Install Cypress
```bash
mkdir "my API test project"
cd "my API test project location"
npm init -y
npm install --save-dev [email protected]
```
- Open Cypress
```bash
npx cypress open
```
- Create a new API test file inside the "cypress/e2e" folder.
- Create Test Case

Test cases are steps that Cypress will run to test the API. Here is an example of how to create a test case using Cypress:

```bash
describe("Kasir API", ()=>{

const baseURL = "https://kasir-api.belajarqa.com/";
it("Sukses login dengan kredensial valid", () => {

const requestBody={
email: "[email protected]",
password: "passwordtokokartiko"
}
cy.request({
method: "POST",
url: `${baseURL}authentications`,
body:requestBody
})
.then ((respone) => {
expect(respone.status).to.eq(201)
expect(respone.body.status).to.eq("success")
expect(respone.body.message).to.eq("Authentication berhasil ditambahkan")
expect(respone.body.data.user.role).to.eq("admin")
expect(respone.headers).to.have.property("content-type", "application/json; charset=utf-8")
})
})
```
- Execute Test Case
After we create a test case, we can run it using Cypress. To run the test case, we can click the run button on Cypress. We will get the test results in the form of a report.
##

0 comments on commit cf05cbf

Please sign in to comment.