microsoft / microsoft/playwright-pytest
[BUG] Tracing does not work with playwright.request.newcontext()
Open
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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