Skip to content

packages/router: npm test requires a working local pytest, skips only when CI=true #83

Description

@bautrey

Problem

packages/router's test script decides whether to run Python tests by checking CI:

if [ "$CI" = "true" ]; then echo 'Skipping Python tests in CI (pytest not available)'; exit 0; else python3 -m pytest tests/test_router.py -v; fi

The comment says the intent is "pytest not available", but the implemented condition is "we are in CI". Those are different things, and they come apart on a developer machine: a contributor with no pytest, or a broken pytest install, gets a hard failure from a plain npm test at the repo root.

Reproduced on macOS with Python 3.14:

$ npm test --workspace=packages/router
ImportError: cannot import name 'FixtureDef' from 'pytest'
npm error Lifecycle script `test` failed with error: code 1

CI=true npm test passes, which is why CI has never caught it. The workaround is undocumented, so the first thing a new contributor sees is a red test run in a repo whose tests are actually fine.

Suggested fix

Gate on the real condition rather than the proxy — probe for a usable pytest and skip with a clear message when it is missing, in CI or not. Something like:

python3 -m pytest --version >/dev/null 2>&1 && python3 -m pytest tests/test_router.py -v || echo 'Skipping Python tests: no usable pytest on PATH'

That keeps the tests running wherever pytest works, including CI if pytest is ever installed there, and stops punishing machines where it is not.

Context

Found while fixing the intra-workspace peer dependency ranges. Deliberately kept out of that PR to keep its diff to one concern.

Same failure shape as the peer-dep bug: a proxy condition standing in for the condition actually meant.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Priority P2bugSomething isn't workingsmall

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions