microsoft / playwright

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
https://playwright.dev
Apache License 2.0
65.47k stars 3.56k forks source link

[Feature]: debug with ability to step through code for API testing #31372

Open BrunoCD opened 2 months ago

BrunoCD commented 2 months ago

🚀 Feature Request

Is it possible to enable debugging for API testing and have the ability to step through the code, like you can when debugging web tests?

Example

using either a flag or in code. npx playwright test --debug-api in code debug=true or debugger or debugger=true

Motivation

for debugging API tests

dgozman commented 2 months ago

Investigation notes

Give the following test:

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

test('get started link', async ({ request }) => {
  await request.get('https://playwright.dev/');
  await request.get('https://playwright.dev/docs/intro');
});

Running with npx playwright test --debug does not bring up the inspector. The reason is that Debugger class is only instantiated for BrowserContext and not for APIRequestContext.

yury-s commented 2 months ago

It would be nice indeed to pause on the API request calls, but current inspector implementation is tightly coupled with browser context. You can use regular JS debugger in VS Code to step over the API requests as a workaround for now.

BrunoCD commented 1 month ago

so there is no update or will not be added as a milestone?