-
Notifications
You must be signed in to change notification settings - Fork 1.2k
E2E test infrastructure improvements #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,34 @@ | ||
| """Shared pytest fixtures for e2e tests.""" | ||
|
|
||
| import pytest | ||
| import pytest_asyncio | ||
|
|
||
| from .testharness import E2ETestContext | ||
|
|
||
|
|
||
| # Track if any test failed to avoid writing corrupted snapshots | ||
| _any_test_failed = False | ||
|
Comment on lines
+9
to
+10
|
||
|
|
||
|
|
||
| @pytest.hookimpl(tryfirst=True, hookwrapper=True) | ||
| def pytest_runtest_makereport(item, call): | ||
| """Track test failures to avoid writing corrupted snapshots.""" | ||
| global _any_test_failed | ||
| outcome = yield | ||
| rep = outcome.get_result() | ||
| if rep.when == "call" and rep.failed: | ||
| _any_test_failed = True | ||
|
|
||
|
|
||
| @pytest_asyncio.fixture(scope="module", loop_scope="module") | ||
| async def ctx(): | ||
| """Create and teardown a test context shared across all tests in this module.""" | ||
| global _any_test_failed | ||
| _any_test_failed = False # Reset for each module | ||
| context = E2ETestContext() | ||
| await context.setup() | ||
| yield context | ||
| await context.teardown() | ||
| await context.teardown(test_failed=_any_test_failed) | ||
|
|
||
|
|
||
| @pytest_asyncio.fixture(autouse=True, loop_scope="module") | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -146,12 +146,13 @@ export class ReplayingCapiProxy extends CapturingHttpProxy { | |||||||||||||||||
|
|
||||||||||||||||||
| // Handle /stop endpoint for stopping the proxy | ||||||||||||||||||
| if ( | ||||||||||||||||||
| options.requestOptions.path === "/stop" && | ||||||||||||||||||
| options.requestOptions.path?.startsWith("/stop") && | ||||||||||||||||||
| options.requestOptions.method === "POST" | ||||||||||||||||||
| ) { | ||||||||||||||||||
| const skipWritingCache = options.requestOptions.path.includes("skipWritingCache=true"); | ||||||||||||||||||
|
||||||||||||||||||
| const skipWritingCache = options.requestOptions.path.includes("skipWritingCache=true"); | |
| let skipWritingCache = false; | |
| const path = options.requestOptions.path; | |
| const queryIndex = path?.indexOf("?"); | |
| if (queryIndex !== undefined && queryIndex !== -1) { | |
| const searchParams = new URLSearchParams(path.substring(queryIndex + 1)); | |
| skipWritingCache = searchParams.get("skipWritingCache") === "true"; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The .NET implementation uses a CI environment variable check as a workaround for lack of test failure detection, while other languages (Go, Python, Node.js) properly detect actual test failures. This means snapshots will always be skipped in CI even for passing tests, which differs from the behavior in other languages and may not align with the PR's stated goal of only skipping on failure. Consider using a more sophisticated approach like capturing test status through ITestOutputHelper or other xUnit extensibility points.