UNPKG

tlc-core-automation-framework-v3-wdio-v9

Version:

Background: - We are following multi-layer automation framework architecture using webdriver.io + cucumber + typescript This core framework has been implemented with generic utility functions and cucumber steps, which can be easily consumed by another fra

92 lines (80 loc) 3.52 kB
import {describe} from "mocha"; import {expect} from "chai"; import {ApiHelpers} from "../e2e/helpers/common-helpers/api-helpers"; describe('Check Common-helpers > api-helpers.ts > getApiRequest()', async () => { it('should have correct response code as 200', async () => { const hostURL = 'https://run.mocky.io/v3' const resource = '/3f5edd6f-2c39-4fd8-b28c-058d5c6d7ed8' const response = await ApiHelpers.getApiRequest(hostURL, resource); const actualStatusCode = response.statusCode; expect(actualStatusCode).to.equal(200); }) }) describe('Check Common-helpers > api-helpers.ts > getApiRequest()', async () => { it('should have correct response body', async () => { const hostURL = 'https://run.mocky.io/v3' const resource = '/3f5edd6f-2c39-4fd8-b28c-058d5c6d7ed8' const response = await ApiHelpers.getApiRequest(hostURL, resource); const responseBody = response.body; expect(responseBody.Message).to.equal('Get Request was successful'); }) }) describe('Check Common-helpers > api-helpers.ts > postApiRequest()', async () => { it('should have correct response code as 201', async () => { const hostURL = 'https://reqres.in' const resource = '/api/users' const response = await ApiHelpers.postApiRequest(hostURL, resource, { "name": "arif", "job": "testing" }); const actualStatusCode = response.statusCode; expect(actualStatusCode).to.equal(201); }) }) describe('Check Common-helpers > api-helpers.ts > postApiRequest()', async () => { it('should have correct response body', async () => { const hostURL = 'https://reqres.in' const resource = '/api/users' const response = await ApiHelpers.postApiRequest(hostURL, resource, { "name": "arif", "job": "testing" }); const responseBody = response.body; expect(responseBody.name).to.equal('arif'); expect(responseBody.job).to.equal('testing'); }) }) describe('Check Common-helpers > api-helpers.ts > deleteApiRequest()', async () => { it('should have correct response code as 201', async () => { const hostURL = 'https://reqres.in' const resource = '/api/users/2' const response = await ApiHelpers.deleteApiRequest(hostURL, resource); const actualStatusCode = response.statusCode; expect(actualStatusCode).to.equal(204); }) }) describe('Check Common-helpers > api-helpers.ts > putApiRequest()', async () => { it('should have correct response code as 201', async () => { const hostURL = 'https://reqres.in' const resource = '/api/users/2' const response = await ApiHelpers.putApiRequest(hostURL, resource, { "name": "arif", "job": "testing" }); const actualStatusCode = response.statusCode; expect(actualStatusCode).to.equal(200); }) }) describe('Check Common-helpers > api-helpers.ts > putApiRequest()', async () => { it('should have correct response body', async () => { const hostURL = 'https://reqres.in' const resource = '/api/users/2' const response = await ApiHelpers.putApiRequest(hostURL, resource, { "name": "arif", "job": "testing" }); const responseBody = response.body; expect(responseBody.name).to.equal('arif'); expect(responseBody.job).to.equal('testing'); }) })