Skip to content

npm lockfile: a bump of a hoisted, undeclared import selects too few tests #244

Closed

Description

@FredApps

collectDependencyChangeTests in src/repo/impact.ts maps a package-lock.json change to the direct dependencies whose locked tree changed, then selects the tests that import those packages. npm hoists transitive dependencies to node_modules/, so code can import a package it never declared. A bump of that package is attributed only to the declaring dependency, and tests that import it directly are skipped. The Yarn and pnpm paths already fall back when the repository imports undeclared packages; the npm path does not.

Repro: package.json depends on left. The lockfile has node_modules/left (depends on inner) and a hoisted node_modules/inner. src/uses-inner.js imports inner, and src/uses-inner.test.js imports it. Bump inner in package-lock.json.

Expected: src/uses-inner.test.js is selected, or the run falls back.

Actual: changedDependencies is [left]. Only the tests of left are selected, src/uses-inner.test.js is not, and there is no fallback.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions