forked from akshayp7/playwright-typescript-playwright-test
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPOST.test.ts
19 lines (13 loc) · 940 Bytes
/
POST.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import { APIActions } from '@lib/APIActions';
import { test } from '@playwright/test';
const apiActions = new APIActions();
test(`postUsers`, { tag: '@API'}, async ({ request }) => {
//* Body Response Params and Body Response Headers are stored in single text file separated by #
const requestBody = JSON.parse((await apiActions.readValuesFromTextFile('postUsers')).split(`#`)[0]);
const response = await request.post(`/api/users`, { data: requestBody });
await apiActions.verifyStatusCode(response);
const responseBodyParams = (await apiActions.readValuesFromTextFile(`postUsers`)).split(`#`)[1];
await apiActions.verifyResponseBody(responseBodyParams, await response.json(), `Response Body`);
const responseBodyHeaders = (await apiActions.readValuesFromTextFile(`postUsers`)).split(`#`)[2];
await apiActions.verifyResponseHeader(responseBodyHeaders, response.headersArray(), `Respomse Headers`);
});