Skip to content

test: port internal-helpers tests to TypeScript#16344

Closed
yosofbadr wants to merge 6 commits into
withastro:mainfrom
yosofbadr:test/port-tests-to-typescript
Closed

test: port internal-helpers tests to TypeScript#16344
yosofbadr wants to merge 6 commits into
withastro:mainfrom
yosofbadr:test/port-tests-to-typescript

Conversation

@yosofbadr
Copy link
Copy Markdown

Summary

Ports all test files in packages/internal-helpers/test/ from JavaScript to TypeScript, as part of the ongoing test migration effort.

  • Renamed create-filter.test.js to create-filter.test.ts with type annotations
  • Renamed path.test.js to path.test.ts with type annotations for test data arrays
  • Renamed request.test.js to request.test.ts with type annotations (e.g., makeRequest helper)
  • Added tsconfig.test.json for test typechecking (following the pattern from packages/astro)
  • Updated package.json test script to use --strip-types with .test.ts glob, and added typecheck:tests script

All 60 tests pass and tsc --project tsconfig.test.json reports no errors.

Closes #16241 (partial)

Test plan

  • pnpm --filter @astrojs/internal-helpers test -- all 60 tests pass
  • pnpm --filter @astrojs/internal-helpers typecheck:tests -- no type errors

Port all three test files in packages/internal-helpers/test/ from
JavaScript to TypeScript:
- create-filter.test.js -> create-filter.test.ts
- path.test.js -> path.test.ts
- request.test.js -> request.test.ts

Add tsconfig.test.json and update package.json to run TypeScript tests
with --strip-types, following the same pattern as packages/astro.

Ref withastro#16241
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 15, 2026

⚠️ No Changeset found

Latest commit: 9771183

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

@yosofbadr yosofbadr marked this pull request as draft April 15, 2026 18:37
The test entry glob only matched .test.js files. Since tests are
being ported to TypeScript (withastro#16241), update the pattern to also
match .test.ts files.
Replace `as string` with `!` assertion to satisfy
@typescript-eslint/non-nullable-type-assertion-style.
@yosofbadr yosofbadr marked this pull request as ready for review April 15, 2026 19:06
The SCSS HMR and actions blog E2E tests are known flaky failures
unrelated to the TypeScript test port changes in this PR.
Comment on lines +256 to +257
'http://\u4F8B\u3048.jp/test',
'\\\\\u4F8B\u3048.jp/test',
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I ask why you changed these Japanese characters to \u unicode code?

@@ -1,4 +1,4 @@
import assert from 'node:assert/strict';
import * as assert from 'node:assert/strict';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

@@ -1,9 +1,9 @@
import assert from 'node:assert/strict';
import * as assert from 'node:assert/strict';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed

Comment on lines +159 to +161
'http://\u00FCser:p\u0101ss@example.com', // Unicode username/password
'http://\u7528\u6237:\u5BC6\u7801@example.com', // Chinese characters
'http://\u0430\u0434\u043C\u0438\u043D:\u043F\u0430\u0440\u043E\u043B\u044C@example.com', // Cyrillic
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert the internal changes of this array

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Port tests to TypeScript

3 participants