How to Execute DELETE Requests in Playwright

HOME

npm install playwright

import { defineConfig } from '@playwright/test';

export default defineConfig({
  reporter: 'html',
});

import { test, expect } from '@playwright/test';

 test('API Testing - DELETE with Playwright', async ({ request }) => {

// Perform a DELETE request
const response = await request.delete('https://jsonplaceholder.typicode.com/posts/1');
     
     // Check the response status code
     expect(response.status()).toBe(200);

      // Parse the response data
     const responseBody = await response.json();
     console.log(responseBody);
     
   });
import { test, expect } from '@playwright/test';
test('API Testing - DELETE with Playwright', async ({ request }) => {
const response = await request.delete('https://jsonplaceholder.typicode.com/posts/1');
expect(response.status()).toBe(200);
 const responseBody = await response.json();
console.log(responseBody);

npx playwright test api_delete_tests.spec.ts

npx playwright show-report

Leave a comment