Skip to content

feat(preflight): clear error when project lacks @playwright/test (v0.1.2) - #4

Merged
Desperado merged 1 commit into
mainfrom
feat/preflight-playwright-check
Jul 9, 2026
Merged

feat(preflight): clear error when project lacks @playwright/test (v0.1.2)#4
Desperado merged 1 commit into
mainfrom
feat/preflight-playwright-check

Conversation

@Desperado

Copy link
Copy Markdown
Contributor

Fixes the real UX sharp edge found during the 0.1.0 smoke test (QUA-1266).

Problem

Running 9l run/9l heal inside a repo that has a package.json but hasn't installed @playwright/test fell through to the bare-spec scaffold path (find_user_project only matches a package.json that depends on @playwright/test). The spec ran in a detached temp project, its fixture/helper imports failed, and heal then tried to "fix" those phantom import errors — masking the real cause (Playwright just isn't installed).

Fix

New CLI preflight ensure_project_ready(spec) called on the original spec at the top of run_one/heal_one, before any scaffold/heal:

  • enclosing package.json with @playwright/test → proceed;
  • enclosing package.json without it → fail fast, exit 2, Tier 2 never runs:
    🐾 error: /path/package.json exists but does not depend on @playwright/test.
    9lives runs your spec against your own Playwright project — install it first:
        npm install -D @playwright/test && npx playwright install
    
  • no enclosing package.json (bare spec) → scaffolds as before.

(Preflight keys on the original spec, not the working copy — the heal path stashes the working copy in a tempdir when there's no project, so a check inside run_spec would miss it.)

Also

  • Bump to 0.1.2.
  • Enrich PyPI classifiers (per-version Python 3.10–3.12, OS Independent, Console, QA topic) for discoverability.

Tests

  • 3 new test_preflight_* (bare ok / real-project ok / missing-playwright raises). Full suite 28 green, ruff clean.
  • Verified end-to-end: 9l heal + 9l run against a react-only package.json emit the message and exit 2 with no Tier 2; bare spec still scaffolds.

Ship: merge → tag v0.1.2git tag -f v1 && git push -f origin v1.

…1.2)

Running 9l in a repo that has a package.json but hasn't installed
@playwright/test previously fell through to the bare-spec scaffold path:
the spec ran detached from the project, its fixture/helper imports failed,
and 'heal' then tried to 'fix' those phantom errors — masking the real
cause (Playwright just isn't installed).

Add a CLI preflight (ensure_project_ready) on the original spec, before
the run/heal loop: if no enclosing package.json depends on @playwright/test
but one exists, fail fast with an actionable message and exit 2 — never
invoking Tier 2. Bare specs (no enclosing package.json) still scaffold.

Also: bump to 0.1.2 and enrich PyPI classifiers (per-version Python, OS,
console, QA topic).
@cursor

cursor Bot commented Jul 9, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

@sigilix

sigilix Bot commented Jul 9, 2026

Copy link
Copy Markdown

Sigilix Overview

Effort: 2/5 (small)

Quality gates

  • ✅ PR title follows convention
  • ✅ PR description is complete
  • ℹ️ PR is linked to an issue — No Closes #N / Closes SIG-N keyword found in PR body or commit messages.

Summary — latest push

Adds a preflight check (ensure_project_ready) that fails fast with an actionable error when a spec resides in a Node project missing @playwright/test, preventing the tool from silently scaffolding a detached project and masking the real issue. The check is wired into both run_one and heal_one before any scaffold or heal logic runs. The PR also bumps the version to 0.1.2 and enriches PyPI classifiers for discoverability.

Important files

File Score Notes Next step
src/ninelives/runner/execute.py 5/5 Introduces the ensure_project_ready preflight guard that differentiates a bare spec from one inside a project missing Playwright, raising a clear RunnerError for the latter. Verify the error message formatting and exit code (2) are consistently handled by the CLI entrypoint so the user sees the full actionable advice.
src/ninelives/cli.py 4/5 Wires ensure_project_ready into run_one and heal_one so the preflight check gates execution before any scaffolding or healing occurs. Confirm that the unhandled RunnerError from ensure_project_ready correctly propagates to the CLI's top-level handler to produce the intended exit code 2.
src/ninelives/runner/project.py 3/5 Adds find_enclosing_package_json to locate any ancestor package.json regardless of its dependencies, enabling the preflight distinction. Add a targeted unit test for find_enclosing_package_json verifying it correctly stops at the nearest ancestor and ignores nested deeper directories.
tests/test_healing.py 3/5 Adds three integration-level tests for the preflight: bare spec passes, real Playwright project passes, and missing Playwright raises RunnerError. Assert the exact exit code (2) in the missing-Playwright test rather than just catching the exception to fully validate the CLI contract.
pyproject.toml 1/5 Bumps version to 0.1.2 and adds PyPI trove classifiers for OS, Console, Python 3.10-3.12, and QA topic. Ensure CI matrix is updated to explicitly test against the newly declared Python 3.10-3.12 classifiers.

Confidence: 5/5

The change introduces a well-scoped, fail-fast guard with full test coverage for the three distinct project states and carries no risk to existing valid workflows.

  • Verify that ensure_project_ready's RunnerError in cli.py is caught by the top-level error handler and exits with code 2 as documented, rather than causing an unhandled traceback.
  • Confirm find_enclosing_package_json correctly handles the edge case where start is the filesystem root and no package.json exists, ensuring it returns None rather than erroring.
  • Check that heal_one's spec.resolve() call before ensure_project_ready guarantees the preflight operates on the original spec path, not a temporary working copy.
  • Ensure the PyPI classifiers for Python 3.10-3.12 are backed by the project's CI matrix.

Suggested labels: bug


Posted · 069ad0c · 0 findings — View review
Dismiss @sigilix dismiss <reason> (not-a-bug | bad-anchor | already-covered | too-minor | wrong-context) · Re-run /sigilix review

@sigilix sigilix Bot added the bug Something isn't working label Jul 9, 2026
@Desperado
Desperado merged commit 9ad53cc into main Jul 9, 2026
5 checks passed
@Desperado
Desperado deleted the feat/preflight-playwright-check branch July 9, 2026 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant