Skip to content

Commit

Permalink
Updated contact file with controller methods
Browse files Browse the repository at this point in the history
  • Loading branch information
dilpreetj committed Aug 7, 2023
1 parent d7de5e9 commit adfcaae
Showing 1 changed file with 8 additions and 21 deletions.
29 changes: 8 additions & 21 deletions tests/contact.api.spec.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
import { test, expect, APIRequestContext, APIResponse } from '@playwright/test';
import { test, expect, APIResponse } from '@playwright/test';
import ContactPage from '../pages/contact.page';
import apiController from '../controller/api.controller';


test.describe('Contact', () => {
let contactPage: ContactPage;
let fakerApi: APIRequestContext;
let randomPerson: APIResponse;

test.beforeAll(async ({ playwright }) => {
fakerApi = await playwright.request.newContext({
baseURL: 'https://jsonplaceholder.typicode.com/'
});

const response = await fakerApi.get('users');
const responseBody = await response.json();
randomPerson = responseBody[0];

const postResponse = await fakerApi
.post('/users/1/todos', {
data: {
"title": "Learn Playwright",
"completed": "false"
}
});

const postResponseBody = await postResponse.json();
console.log(postResponseBody);
test.beforeAll(async () => {
await apiController.init();
randomPerson = await apiController.getUsers();
const newUserTodo = await apiController.createUserTodo();
console.log(newUserTodo);
})


Expand Down

0 comments on commit adfcaae

Please sign in to comment.