Skip to content

Commit 2021d75

Browse files
committed
added api test to verify a value from the response's body and a negative test to verify a 404 status code
1 parent 563a454 commit 2021d75

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

cypress/integration/api/pokeapi.spec.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// <reference types="Cypress" />
2-
import { pokeapi_base_url } from '../../../config'
2+
import { pokeapi_base_url, url } from '../../../config'
33

44
describe('Rest API Test with Cypress', () => {
55
it('API Test - Validate Header', () => {
@@ -18,4 +18,23 @@ describe('Rest API Test with Cypress', () => {
1818
.its('status')
1919
.should('equal', 200)
2020
})
21+
22+
it('API Test - Validate Name Value', () => {
23+
cy.request(`${pokeapi_base_url}v2/pokemon/25`).as('pokemon')
24+
cy.get('@pokemon')
25+
.its('body')
26+
.should('include', { name: 'pikachu' })
27+
})
28+
29+
it('API Test - Validate Negative Status Code', () => {
30+
cy.request({
31+
method: 'GET',
32+
url: `${pokeapi_base_url}v2/pokemon/10000`,
33+
failOnStatusCode: false
34+
}).as('pokemon')
35+
cy.get('@pokemon')
36+
.its('status')
37+
.should('equal', 404)
38+
39+
})
2140
})

0 commit comments

Comments
 (0)