Skip to content

Commit 6f96b25

Browse files
authored
cy: improve api comments & contacts assertions and readability (#1604)
* cy: improve api comments & contacts assertions and readability * remove assertion
1 parent 8319a37 commit 6f96b25

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

cypress/tests/api/api-comments.spec.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,18 @@ describe("Comments API", function () {
3434

3535
context("GET /comments/:transactionId", function () {
3636
it("gets a list of comments for a transaction", function () {
37-
cy.request("GET", `${apiComments}/${ctx.transactionId}`).then((response) => {
37+
const transactionId = ctx.transactionId!;
38+
cy.request("GET", `${apiComments}/${transactionId}`).then((response) => {
3839
expect(response.status).to.eq(200);
39-
expect(response.body.comments.length).to.eq(1);
40+
expect(response.body.comments).to.be.an("array").that.has.length(1);
4041
});
4142
});
4243
});
4344

4445
context("POST /comments/:transactionId", function () {
4546
it("creates a new comment for a transaction", function () {
46-
cy.request("POST", `${apiComments}/${ctx.transactionId}`, {
47+
const transactionId = ctx.transactionId!;
48+
cy.request("POST", `${apiComments}/${transactionId}`, {
4749
content: "This is my comment",
4850
}).then((response) => {
4951
expect(response.status).to.eq(200);

cypress/tests/api/api-contacts.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe("Contacts API", function () {
6363
},
6464
}).then((response) => {
6565
expect(response.status).to.eq(422);
66-
expect(response.body.errors.length).to.eq(1);
66+
expect(response.body.errors).to.be.an("array").that.has.length(1);
6767
});
6868
});
6969
});

0 commit comments

Comments
 (0)