Skip to content

Conversation

@Archmonger
Copy link
Contributor

@ArchmongerArchmonger commented Dec 12, 2025

Description

Test runner takes a long time to run, even on a high performance Windows machine. This is largely due to Playwright startup/shutdown being slow.

This PR does the following

  • Changes to test suite to allow hatch (pytest) to run in parallel mode
  • Changes to the build process to avoid extraneous rebuilds in parallel mode
  • Fix bugs in source code which caused flaky tests (related to ReactJS double-mounting)
  • Move some functions around
  • Pin package versions within component_from_npm tests

On my local machine: Reduced from ~150 seconds to ~20 seconds.
On GitHub Actions: Reduced from ~15 minutes to ~5 minutes.

Checklist

Please update this checklist as you complete each item:

  • Tests have been developed for bug fixes or new functionality.
  • The changelog has been updated, if necessary.
  • Documentation has been updated, if necessary.
  • GitHub Issues closed by this PR have been linked.

By submitting this pull request I agree that all contributions comply with this project's open source license(s).

@ArchmongerArchmonger marked this pull request as ready for review December 14, 2025 04:38
Copy link

CopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR significantly improves test runner performance by enabling parallel test execution and addressing related infrastructure issues. The changes reduce test execution time from ~150 seconds to ~20 seconds locally and from ~15 minutes to ~6 minutes in CI.

Key improvements include:

  • Session-scoped browser fixtures to avoid repeated Playwright startup/shutdown
  • File locking mechanism to prevent race conditions during parallel module registration
  • Dynamic port allocation for test servers
  • React/Preact framework detection to handle double-mounting correctly
  • Unique module names in tests to prevent conflicts in parallel execution

Reviewed changes

Copilot reviewed 44 out of 47 changed files in this pull request and generated 4 comments.

Show a summary per file
FileDescription
tests/conftest.pyConverted fixtures to session scope, removed rebuild logic, simplified browser initialization
src/reactpy/testing/display.pyAdded browser/backend externality tracking, improved page configuration, added visibility helper
src/reactpy/testing/backend.pyImplemented dynamic port allocation (port=0), added server startup validation loop
src/reactpy/testing/common.pyRemoved clear_reactpy_web_modules_dir utility (no longer needed with locking)
src/reactpy/reactjs/utils.pyAdded file locking for module registration, improved atomic file copy operations
src/reactpy/reactjs/module.pyIntegrated file locking, added import_reactjs helper with framework selection
src/js/packages/@reactpy/client/src/bind.tsxNew file implementing framework detection and binding logic
src/js/packages/@reactpy/client/src/vdom.tsxRefactored to use framework detection, fixed double-mount issues
src/js/packages/@reactpy/client/src/components.tsxFixed race conditions in binding lifecycle
tests/test_web/test_module.pyMade module names unique, added display fixture override, fixed browser parameter
tests/test_reactjs/test_modules_from_npm.pyPinned package versions, converted to module-scoped fixtures, improved assertions
tests/test_reactjs/test_utils.pyUpdated function names from resolve_from_* to resolve_names_from_*
pyproject.tomlAdded parallel test support, reorganized build scripts, updated test configuration
.github/workflows/check.ymlAdded --parallel flag to test commands

@ArchmongerArchmonger merged commit f21e963 into reactive-python:mainDec 14, 2025
37 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@Archmonger