From 54b8b626ddd05f29710eb0e6bbd629e49742c4ac Mon Sep 17 00:00:00 2001 From: ocavue Date: Tue, 21 Apr 2026 05:36:22 +1000 Subject: [PATCH 1/3] refactor(ts-plugin): migrate tests to typescript --- .../{.vscode-test.js => .vscode-test.mjs} | 7 ++-- .../language-tools/ts-plugin/package.json | 5 ++- .../{extension.test.js => extension.test.mts} | 21 ++++++----- .../ts-plugin/tsconfig.test.json | 13 +++++++ pnpm-lock.yaml | 35 +++++++++++++------ 5 files changed, 59 insertions(+), 22 deletions(-) rename packages/language-tools/ts-plugin/{.vscode-test.js => .vscode-test.mjs} (52%) rename packages/language-tools/ts-plugin/test/suite/{extension.test.js => extension.test.mts} (80%) create mode 100644 packages/language-tools/ts-plugin/tsconfig.test.json diff --git a/packages/language-tools/ts-plugin/.vscode-test.js b/packages/language-tools/ts-plugin/.vscode-test.mjs similarity index 52% rename from packages/language-tools/ts-plugin/.vscode-test.js rename to packages/language-tools/ts-plugin/.vscode-test.mjs index de1ce81d4b3a..f91e86fbfa36 100644 --- a/packages/language-tools/ts-plugin/.vscode-test.js +++ b/packages/language-tools/ts-plugin/.vscode-test.mjs @@ -1,14 +1,15 @@ -const { defineConfig } = require('@vscode/test-cli'); +import { defineConfig } from '@vscode/test-cli'; -module.exports = defineConfig([ +export default defineConfig([ { label: 'unitTests', - files: 'test/**/*.test.js', + files: 'test/**/*.test.mts', extensionDevelopmentPath: '../vscode', version: 'stable', mocha: { ui: 'tdd', timeout: 20000, + require: ['tsx'], }, }, ]); diff --git a/packages/language-tools/ts-plugin/package.json b/packages/language-tools/ts-plugin/package.json index 0d63cc569265..2890edccff5d 100644 --- a/packages/language-tools/ts-plugin/package.json +++ b/packages/language-tools/ts-plugin/package.json @@ -22,7 +22,8 @@ "scripts": { "build": "tsc", "dev": "tsc --watch", - "test": "vscode-test" + "test": "vscode-test", + "typecheck:tests": "tsc --build tsconfig.test.json" }, "author": "withastro", "license": "MIT", @@ -39,9 +40,11 @@ "@types/mocha": "^10.0.10", "@types/node": "^20.9.0", "@types/semver": "^7.7.1", + "@types/vscode": "^1.92.0", "@vscode/test-cli": "^0.0.12", "@vscode/test-electron": "^2.5.2", "mocha": "^11.7.5", + "tsx": "^4.21.0", "typescript": "^5.9.3", "vscode-uri": "^3.1.0" } diff --git a/packages/language-tools/ts-plugin/test/suite/extension.test.js b/packages/language-tools/ts-plugin/test/suite/extension.test.mts similarity index 80% rename from packages/language-tools/ts-plugin/test/suite/extension.test.js rename to packages/language-tools/ts-plugin/test/suite/extension.test.mts index 08f4ed144ebc..a63b27ff7d99 100644 --- a/packages/language-tools/ts-plugin/test/suite/extension.test.js +++ b/packages/language-tools/ts-plugin/test/suite/extension.test.mts @@ -1,14 +1,19 @@ -const assert = require('node:assert'); -const path = require('node:path'); -const vscode = require('vscode'); +import 'mocha'; +import assert from 'node:assert'; +import path from 'node:path'; +import * as vscode from 'vscode'; suite('Extension Test Suite', () => { vscode.window.showInformationMessage('Start all tests.'); // TypeScript takes a while to wake up and there's unfortunately no good way to wait for it - async function waitForTS(command, commandArgs, condition) { + async function waitForTS( + command: string, + commandArgs: unknown[], + condition: (result: T) => boolean, + ): Promise { for (let i = 0; i < 2000; i++) { - const commandResult = await vscode.commands.executeCommand(command, ...commandArgs); + const commandResult = await vscode.commands.executeCommand(command, ...commandArgs); if (condition(commandResult)) { return commandResult; } @@ -24,7 +29,7 @@ suite('Extension Test Suite', () => { vscode.Uri.file(path.join(__dirname, '../fixtures/script.ts')), ); - const references = await waitForTS( + const references = await waitForTS( 'vscode.executeReferenceProvider', [doc.uri, new vscode.Position(0, 18)], (result) => result.length > 1, @@ -39,7 +44,7 @@ suite('Extension Test Suite', () => { vscode.Uri.file(path.join(__dirname, '../fixtures/script.ts')), ); - const completions = await waitForTS( + const completions = await waitForTS( 'vscode.executeCompletionItemProvider', [doc.uri, new vscode.Position(4, 12)], (result) => result.items.length > 0, @@ -56,7 +61,7 @@ suite('Extension Test Suite', () => { vscode.Uri.file(path.join(__dirname, '../fixtures/script.ts')), ); - const implementations = await waitForTS( + const implementations = await waitForTS( 'vscode.executeImplementationProvider', [doc.uri, new vscode.Position(6, 15)], (result) => result.length > 1, diff --git a/packages/language-tools/ts-plugin/tsconfig.test.json b/packages/language-tools/ts-plugin/tsconfig.test.json new file mode 100644 index 000000000000..3ad1bbfc413f --- /dev/null +++ b/packages/language-tools/ts-plugin/tsconfig.test.json @@ -0,0 +1,13 @@ +{ + "extends": "../../../tsconfig.base.json", + "include": ["test/**/*.mts", "test/**/*.ts", ".vscode-test.*"], + "exclude": ["test/fixtures/**"], + "compilerOptions": { + "types": ["node"], + "allowJs": true, + "noUnusedLocals": false, + "noUnusedParameters": false, + "rewriteRelativeImportExtensions": true + }, + "references": [{ "path": "../../astro/tsconfig.test.json" }] +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 693a6fa46bef..9d30ea87eb30 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -122,10 +122,10 @@ importers: devDependencies: '@codspeed/vitest-plugin': specifier: 5.2.0 - version: 5.2.0(tinybench@2.9.0)(vite@7.3.1(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3))(vitest@4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(vite@7.3.1(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3))) + version: 5.2.0(tinybench@2.9.0)(vite@7.3.1(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3))(vitest@4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3)) vitest: specifier: ^4.1.0 - version: 4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(vite@7.3.1(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3)) + version: 4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3) benchmark/packages/adapter: dependencies: @@ -232,7 +232,7 @@ importers: version: 18.3.1(react@18.3.1) vitest: specifier: ^4.1.0 - version: 4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(vite@7.3.1(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3)) + version: 4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3) devDependencies: '@types/react': specifier: ^18.3.28 @@ -506,7 +506,7 @@ importers: version: link:../../packages/astro vitest: specifier: ^4.1.0 - version: 4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(vite@7.3.1(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3)) + version: 4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3) packages/astro: dependencies: @@ -765,7 +765,7 @@ importers: version: 11.0.5 vitest: specifier: ^4.1.0 - version: 4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(vite@7.3.1(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3)) + version: 4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3) optionalDependencies: sharp: specifier: ^0.34.0 @@ -4248,7 +4248,7 @@ importers: version: link:../../.. vitest: specifier: ^4.1.0 - version: 4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(vite@7.3.1(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3)) + version: 4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3) packages/astro/test/fixtures/vue-component: dependencies: @@ -6690,6 +6690,9 @@ importers: '@types/semver': specifier: ^7.7.1 version: 7.7.1 + '@types/vscode': + specifier: ^1.92.0 + version: 1.109.0 '@vscode/test-cli': specifier: ^0.0.12 version: 0.0.12 @@ -6699,6 +6702,9 @@ importers: mocha: specifier: ^11.7.5 version: 11.7.5 + tsx: + specifier: ^4.21.0 + version: 4.21.0 typescript: specifier: ^5.9.3 version: 5.9.3 @@ -15503,7 +15509,6 @@ packages: '@vitest/ui': 4.1.0 happy-dom: '*' jsdom: '*' - vite: ^6.0.0 || ^7.0.0 || ^8.0.0-0 peerDependenciesMeta: '@edge-runtime/vm': optional: true @@ -16618,12 +16623,12 @@ snapshots: transitivePeerDependencies: - debug - '@codspeed/vitest-plugin@5.2.0(tinybench@2.9.0)(vite@7.3.1(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3))(vitest@4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(vite@7.3.1(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3)))': + '@codspeed/vitest-plugin@5.2.0(tinybench@2.9.0)(vite@7.3.1(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3))(vitest@4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3))': dependencies: '@codspeed/core': 5.2.0 tinybench: 2.9.0 vite: 7.3.1(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3) - vitest: 4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(vite@7.3.1(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3)) + vitest: 4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3) transitivePeerDependencies: - debug @@ -25397,7 +25402,7 @@ snapshots: optionalDependencies: vite: 7.3.1(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3) - vitest@4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(vite@7.3.1(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3)): + vitest@4.1.0(@opentelemetry/api@1.9.0)(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3): dependencies: '@vitest/expect': 4.1.0 '@vitest/mocker': 4.1.0(vite@7.3.1(@types/node@25.2.3)(jiti@2.6.1)(lightningcss@1.32.0)(sass@1.98.0)(tsx@4.21.0)(yaml@2.8.3)) @@ -25423,7 +25428,17 @@ snapshots: '@opentelemetry/api': 1.9.0 '@types/node': 25.2.3 transitivePeerDependencies: + - jiti + - less + - lightningcss - msw + - sass + - sass-embedded + - stylus + - sugarss + - terser + - tsx + - yaml volar-service-css@0.0.70(@volar/language-service@2.4.28): dependencies: From d1d51e245fe2aa8edea537f323858f8b9e22c814 Mon Sep 17 00:00:00 2001 From: ocavue Date: Tue, 21 Apr 2026 07:31:48 +1000 Subject: [PATCH 2/3] chore: trigger ci From 3a9e685ed47ec44fa8df3ff740622d232db2a0da Mon Sep 17 00:00:00 2001 From: ocavue Date: Tue, 21 Apr 2026 21:09:03 +1000 Subject: [PATCH 3/3] Update ci.yml --- .github/workflows/ci.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 632c12e85ba8..bc1d16065495 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -251,9 +251,13 @@ jobs: pnpm run test:language-tools:no-vs cd packages/language-tools/vscode xvfb-run -a pnpm test - # TODO: Figure out why the vscode tests are fine, but the ts-plugin ones are super flaky - # cd ../ts-plugin - # xvfb-run -a pnpm test + + - name: Test ts-plugin (Linux, flaky) + if: runner.os == 'Linux' + timeout-minutes: 10 + working-directory: packages/language-tools/ts-plugin + # TODO: Figure out why the vscode tests are fine, but the ts-plugin ones are super flaky + run: xvfb-run -a pnpm test || echo "::warning title=ts-plugin tests failed::Known flaky; not failing CI." - name: Test if: runner.os != 'Linux'