microsoft / microsoft/playwright-pytest

[BUG] Tracing does not work with playwright.request.newcontext()

Open
#137 5 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

p3-collecting-feedback
Dominant language
Python
Stars
563
Forks
90
Avg merge
11m
Merged PRs (30d)
1

Description

Context:
I am using playwright to test REST API endpoints.
I do not see trace.zip after I run pytest --tracing=on.

Code Snippet

Simple test script

import os
from typing import Generator

import pytest
from playwright.sync_api import Playwright, APIRequestContext


@pytest.fixture(scope="session")
def api_request_context(
    playwright: Playwright,
) -> Generator[APIRequestContext, None, None]:
    request_context = playwright.request.new_context(
        base_url="https://api.publicapis.org",
        ignore_https_errors=True
    )
    yield request_context
    request_context.dispose()

def test_should_create_bug_report(api_request_context: APIRequestContext) -> None:
    response = api_request_context.get("/entries")
    assert response.ok

Describe the bug

pytest --tracing=on test_mytest.py does not produce trace.zip

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided test_mytest.py example with pytest --tracing=on and inspect how the session-scoped APIRequestContext is created and disposed. Reproduce the missing trace.zip behavior, then verify that tracing produces the expected archive for this request-based test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.