Skip to content

Commit 15a59e3

Browse files
committed
added two test to check for status and response to a request made to api.chucknorris.io
1 parent 2021d75 commit 15a59e3

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export const url = 'http://zero.webappsecurity.com/index.html'
22
export const login_username = 'username'
33
export const login_password = 'password'
4-
export const pokeapi_base_url = "https://pokeapi.co/api/"
4+
export const pokeapi_base_url = "https://pokeapi.co/api/"
5+
export const chucknorrisapi_base_url = 'https://api.chucknorris.io/'
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
///<reference types ="Cypress" />
2+
import { chucknorrisapi_base_url } from '../../../config'
3+
4+
beforeEach(() => {
5+
cy.log('starting test')
6+
})
7+
8+
describe('REST API Tests for api.chuchnorris.io', () => {
9+
it('API Test - Validate Status Code', () => {
10+
cy.request(`${chucknorrisapi_base_url}jokes/random`).as('joke')
11+
cy.get('@joke').its('status').should('equal', 200)
12+
})
13+
14+
it('API Test - Validate body does contain a joke in the value field', () => {
15+
cy.request(`${chucknorrisapi_base_url}jokes/random`).as('joke')
16+
cy.get('@joke')
17+
.its('body')
18+
.should('have.property', 'value')
19+
.and('be.a', 'string')
20+
})
21+
})

0 commit comments

Comments
 (0)