Skip to content

Impact: a script the test script runs directly (node scripts/check.mjs && node --test) is skipped, so verify passes while npm test fails #305

Closed

Description

@FredApps

A JavaScript file that the root package.json test script runs itself, such as "test": "node scripts/check.mjs && node --test", is part of the suite. No test imports it, though. When tsconfig.json includes it, the graph sees only an entry point (NEXT_ENTRY_POINT evidence). A change to it, or to code it imports, then selects nothing for it and adds no fallback reason. verify passes while npm test fails.

Repro:

git init ep && cd ep && mkdir src test scripts
echo 'export const a = () => 1;' > src/a.js
printf "import test from 'node:test';\nimport assert from 'node:assert/strict';\nimport { a } from '../src/a.js';\ntest('a', () => assert.equal(a(), 1));\n" > test/a.test.js
echo 'console.log("data ok");' > scripts/check.mjs
echo '{"name":"x","type":"module","scripts":{"test":"node scripts/check.mjs && node --test"}}' > package.json
echo '{"compilerOptions":{"allowJs":true,"module":"nodenext","noEmit":true},"include":["src","test","scripts"]}' > tsconfig.json
git add -A && git commit -qm base
echo 'console.error("data broken"); process.exit(1);' > scripts/check.mjs
echo 'export const a = () => 1; // edit' > src/a.js
git commit -qam head
diffci plan --repo . --base HEAD~1      # or: diffci verify --base HEAD~1 --head HEAD
npm test; echo $?

Expected: the change runs node scripts/check.mjs as a test-script phase (verify already runs such phases for data files), or falls back to the full suite.

Actual: the plan is SELECTIVE with selectedTests: ["test/a.test.js"] and no fallback reason. The only evidence for scripts/check.mjs is NEXT_ENTRY_POINT. diffci verify --base HEAD~1 --head HEAD reports PASSED and runs node --test test/a.test.js. npm test exits 1 ("data broken").

The same happens when the program runs after the runner (node --test && node scripts/check.mjs), when it is reached through another script (npm run check), and when the changed file is a module that scripts/check.mjs imports. Data files that the test script names are already handled (directTestPhases in file-references.ts). Code files never reach that resolution.

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