MOB-49400: Fix Playwright frozen-version check - #1985
Merged
Conversation
`npm list` defaults to --depth=0 on npm>=7 and `playwright` is a transitive dep of `@playwright/test`, so the substring check never matched even when the installed version was correct — triggering an unnecessary re-install that fails for rootless runs. Probe the version via `npx --no -- <pkg> --version` from `self.tools_dir`, matching the freeze step in taurus-cloud Dockerfile-reduced. The drift-recovery re-install path is unchanged.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates Playwright “frozen version” detection to avoid false positives that were causing unnecessary reinstalls, by switching the installed-version check from npm list output parsing to a direct version probe.
Changes:
- Replace
npm list-based frozen-version detection withnpx --no -- … --versionprobes for both Playwright and@playwright/test. - Update/extend unit tests to assert the new probe command and
cwdusage. - Adjust test naming/docstrings to reflect the new “version probe” behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
bzt/modules/javascript.py |
Switches frozen-version checks to npx --no … --version and parses the probed version. |
tests/unit/modules/_selenium/test_javascript.py |
Updates unit tests to expect the new probe commands and cwd behavior. |
Comments suppressed due to low confidence (4)
bzt/modules/javascript.py:555
- The warning message still says "Frozen version not found in installed packages" even though the logic no longer scans a package list; it compares a probed version string. Updating the message to reflect a version mismatch (and ideally include expected vs installed) would make troubleshooting clearer.
if version_changed:
self.log.warning("Frozen version not found in installed packages, will re-install %s", self.PACKAGE_NAME)
return not version_changed
bzt/modules/javascript.py:550
- This introduces another hard-coded
"npx"invocation. On Windows the executable is typicallynpx.cmd(similar to howNPM.check_if_installed()searches fornpm.cmd). To avoid platform-specific failures (and false "version_changed"), consider resolving thenpxexecutable path in the same way asnpm(e.g., via a smallNPXtool helper that triesnpx/npx.cmd) and use that resolved path here.
# `npx --no` reads the locally-installed version without fetching from the
# registry. Mirrors the freeze step in taurus-cloud Dockerfile-reduced.
cmdline = ["npx", "--no", "--", "@playwright/test", "--version"]
try:
out, _ = self.call(cmdline, cwd=self.tools_dir)
bzt/modules/javascript.py:592
- The warning message mentions "not found in installed packages" but the new check is a direct version probe (
playwright --version). Consider adjusting the wording to reflect a version mismatch/probe failure so operators understand what was checked and why a reinstall is happening.
installed = (out or "").strip().split()[-1] if (out or "").strip() else ""
version_changed = installed != frozen_version
if version_changed:
self.log.warning("Frozen version not found in installed packages, will re-install %s", package_name)
except CALL_PROBLEMS as exc:
bzt/modules/javascript.py:588
- Like the
PlaywrightTestPackageprobe above, this new version check hard-codes"npx". Ifnpm.cmdis selected on Windows,npxmay still need to benpx.cmd; resolvingnpxvia a helper (similar toNPM.check_if_installed()) would make the version-check path more reliable cross-platform.
# `npx --no` reads the locally-installed version without fetching from the
# registry. Mirrors the freeze step in taurus-cloud Dockerfile-reduced.
cmdline = ["npx", "--no", "--", "playwright", "--version"]
try:
out, _ = self.call(cmdline, cwd=self.tools_dir)
installed = (out or "").strip().split()[-1] if (out or "").strip() else ""
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
pavelmarik
approved these changes
May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixed check of installed version - no unecessary re-install triggered.