Skip to content

fix(test): align test:match and test:cli script globs with .test.ts files#16648

Open
aru-dev-ac wants to merge 2 commits into
withastro:mainfrom
aru-dev-ac:fix/align-test-scripts-after-typescript-migration
Open

fix(test): align test:match and test:cli script globs with .test.ts files#16648
aru-dev-ac wants to merge 2 commits into
withastro:mainfrom
aru-dev-ac:fix/align-test-scripts-after-typescript-migration

Conversation

@aru-dev-ac
Copy link
Copy Markdown

Changes

After #16402 migrated every test under packages/astro/test to TypeScript, two scripts in packages/astro/package.json were left pointing at non-existent .test.js globs:

"test:match": "astro-scripts test \"test/**/*.test.js\" --match",
"test:cli":   "astro-scripts test \"test/**/cli.test.js\"",

Because astro-scripts test wraps the matched files in a temp module before invoking node:test (see scripts/cmd/test.js:90-102), an empty match still produces a passing run — node:test counts the empty wrapper as a single passing "test" — so the breakage was silent. pnpm test:cli reports tests 1, pass 1, suites 0 and exits in ~100ms without ever executing the real CLI tests in test/cli.test.ts.

This PR:

  • Updates the globs to .test.ts so they match real files (test/cli.test.ts, test/units/**/*.test.ts, test/*.test.ts).
  • Adds --strip-types so node:test can load the TypeScript files, matching the existing test:unit and test:integration scripts on the surrounding lines.
  • Restores test:match as the documented "run a subset of tests by name pattern" command referenced in CONTRIBUTING.md lines 130-132.

Testing

Verified locally before/after the change:

Beforepnpm test:cli (phantom pass, no real tests run):

> astro-scripts test "test/**/cli.test.js"
✔ /workspaces/astro/packages/astro/node_modules/.astro/test.mjs (90ms)
ℹ tests 1   ℹ suites 0   ℹ pass 1

Afterpnpm test:cli --match "astro --version" (real cli.test.ts test):

> astro-scripts test "test/**/cli.test.ts" --strip-types --match 'astro --version'
▶ astro cli
  ✔ astro --version (338ms)
✔ astro cli (339ms)
ℹ tests 1   ℹ suites 1   ℹ pass 1

Note the suite count flips from 0 → 1, confirming cli.test.ts is actually loaded and the describe('astro cli') suite runs.

Docs

No docs changes needed — CONTRIBUTING.md:130-132 already documents pnpm test:match "<pattern>"; this PR makes that documented behaviour work again.

No changeset added — internal-only package.json script change, no published-package surface affected.

…iles

After withastro#16402 migrated every test under packages/astro/test to TypeScript,
two scripts in packages/astro/package.json were left pointing at non-existent
.test.js globs:

  "test:match": "astro-scripts test \"test/**/*.test.js\" --match",
  "test:cli":   "astro-scripts test \"test/**/cli.test.js\"",

Because astro-scripts wraps the matched files in a temp module before invoking
node:test, an empty match still produces a passing run (one phantom "1 test"
from the empty wrapper), so the breakage was silent.

This commit:

- updates the globs to .test.ts so they match real files
  (test/cli.test.ts, test/units/**/*.test.ts, test/*.test.ts);
- adds --strip-types so node:test can load the TypeScript files,
  matching the existing test:unit and test:integration scripts;
- restores test:match as the documented "run a subset of tests by
  name pattern" command referenced in CONTRIBUTING.md.

Verified locally: "pnpm test:cli --match 'astro --version'" now runs
the real "astro cli > astro --version" test from test/cli.test.ts,
where previously it reported a phantom "1 test passed" without
executing any cli.test code.
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 7, 2026

⚠️ No Changeset found

Latest commit: 9911ac7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions Bot added the pkg: astro Related to the core `astro` package (scope) label May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant