diff --git a/packages/astro/test/scoped-style-strategy.test.js b/packages/astro/test/scoped-style-strategy.test.ts similarity index 86% rename from packages/astro/test/scoped-style-strategy.test.js rename to packages/astro/test/scoped-style-strategy.test.ts index c1a76aabbf22..0b6c748e4a48 100644 --- a/packages/astro/test/scoped-style-strategy.test.js +++ b/packages/astro/test/scoped-style-strategy.test.ts @@ -1,13 +1,12 @@ import assert from 'node:assert/strict'; import { before, describe, it } from 'node:test'; import * as cheerio from 'cheerio'; -import { loadFixture } from './test-utils.js'; +import { type Fixture, loadFixture } from './test-utils.js'; describe('scopedStyleStrategy', () => { describe('scopedStyleStrategy: "where"', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; - let stylesheet; + let fixture: Fixture; + let stylesheet: string; before(async () => { fixture = await loadFixture({ @@ -21,7 +20,7 @@ describe('scopedStyleStrategy', () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); const $link = $('link[rel=stylesheet]'); - const href = $link.attr('href'); + const href = $link.attr('href')!; stylesheet = await fixture.readFile(href); }); @@ -35,9 +34,8 @@ describe('scopedStyleStrategy', () => { }); describe('scopedStyleStrategy: "class"', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; - let stylesheet; + let fixture: Fixture; + let stylesheet: string; before(async () => { fixture = await loadFixture({ @@ -51,7 +49,7 @@ describe('scopedStyleStrategy', () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); const $link = $('link[rel=stylesheet]'); - const href = $link.attr('href'); + const href = $link.attr('href')!; stylesheet = await fixture.readFile(href); }); @@ -65,9 +63,8 @@ describe('scopedStyleStrategy', () => { }); describe('default', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; - let stylesheet; + let fixture: Fixture; + let stylesheet: string; before(async () => { fixture = await loadFixture({ @@ -80,7 +77,7 @@ describe('scopedStyleStrategy', () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); const $link = $('link[rel=stylesheet]'); - const href = $link.attr('href'); + const href = $link.attr('href')!; stylesheet = await fixture.readFile(href); }); diff --git a/packages/astro/test/serializeManifest.test.js b/packages/astro/test/serializeManifest.test.ts similarity index 95% rename from packages/astro/test/serializeManifest.test.js rename to packages/astro/test/serializeManifest.test.ts index 2a36352ede93..96085367880c 100644 --- a/packages/astro/test/serializeManifest.test.js +++ b/packages/astro/test/serializeManifest.test.ts @@ -4,12 +4,11 @@ import * as cheerio from 'cheerio'; import { ServerOnlyModule } from '../dist/core/errors/errors-data.js'; import { AstroError } from '../dist/core/errors/index.js'; import testAdapter from './test-adapter.js'; -import { loadFixture } from './test-utils.js'; +import { type App, type DevServer, type Fixture, loadFixture } from './test-utils.js'; describe('astro:config/client', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; - let devServer; + let fixture: Fixture; + let devServer: DevServer; describe('in dev', async () => { before(async () => { @@ -90,8 +89,7 @@ describe('astro:config/client', () => { }); describe('astro:config/client in a client script', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; + let fixture: Fixture; describe('when build', () => { before(async () => { @@ -110,10 +108,9 @@ describe('astro:config/client in a client script', () => { }); describe('astro:config/server', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; - let devServer; - let app; + let fixture: Fixture; + let devServer: DevServer; + let app: App; describe('when build', () => { before(async () => { diff --git a/packages/astro/test/server-entry.test.js b/packages/astro/test/server-entry.test.ts similarity index 81% rename from packages/astro/test/server-entry.test.js rename to packages/astro/test/server-entry.test.ts index 102ab25c0e90..bf8b492590a2 100644 --- a/packages/astro/test/server-entry.test.js +++ b/packages/astro/test/server-entry.test.ts @@ -1,17 +1,26 @@ -// @ts-check - import { describe, it } from 'node:test'; -import { loadFixture } from './test-utils.js'; +import { type App, type Fixture, loadFixture } from './test-utils.js'; import testAdapter, { selfTestAdapter } from './test-adapter.js'; import assert from 'node:assert/strict'; -import fakeAdapter from './fixtures/server-entry/fake-adapter/index.js'; import { existsSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; +import type { AstroIntegration } from 'astro'; + +type FakeAdapter = ( + options: + | { type: 'rollupInput'; shape: 'string' | 'object' | 'array' } + | { type: 'serverEntrypoint' }, +) => AstroIntegration; + +const fakeAdapter: FakeAdapter = await (async () => { + const importPath: string = './fixtures/server-entry/fake-adapter/index.js'; + const mod = await import(importPath); + return mod.default; +})(); describe('Server entry', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; - let app; + let fixture: Fixture; + let app: App; it('should load the custom entry when using legacy entrypoint', async () => { fixture = await loadFixture({ @@ -23,7 +32,7 @@ describe('Server entry', () => { }, }); - await fixture.build({}); + await fixture.build(); app = await fixture.loadTestAdapterApp(false); const request = new Request('http://example.com/'); @@ -41,7 +50,7 @@ describe('Server entry', () => { }, }); - await fixture.build({}); + await fixture.build(); app = await fixture.loadSelfAdapterApp(false); const request = new Request('http://example.com/'); @@ -59,7 +68,7 @@ describe('Server entry', () => { }, }); - await fixture.build({}); + await fixture.build(); assert.ok(existsSync(fileURLToPath(new URL('server/custom.mjs', fixture.config.outDir)))); }); @@ -74,7 +83,7 @@ describe('Server entry', () => { }, }); - await fixture.build({}); + await fixture.build(); assert.ok(existsSync(fileURLToPath(new URL('server/custom.mjs', fixture.config.outDir)))); }); @@ -89,7 +98,7 @@ describe('Server entry', () => { }, }); - await fixture.build({}); + await fixture.build(); assert.ok(existsSync(fileURLToPath(new URL('server/custom.mjs', fixture.config.outDir)))); }); @@ -104,7 +113,7 @@ describe('Server entry', () => { }, }); - await fixture.build({}); + await fixture.build(); assert.ok(existsSync(fileURLToPath(new URL('server/custom.mjs', fixture.config.outDir)))); }); diff --git a/packages/astro/test/server-islands.test.js b/packages/astro/test/server-islands.test.ts similarity index 94% rename from packages/astro/test/server-islands.test.js rename to packages/astro/test/server-islands.test.ts index 9ffcf5b941a7..15baf2d5801d 100644 --- a/packages/astro/test/server-islands.test.js +++ b/packages/astro/test/server-islands.test.ts @@ -5,10 +5,10 @@ import * as cheerio from 'cheerio'; import { encryptString } from '../dist/core/encryption.js'; import testAdapter from './test-adapter.js'; -import { loadFixture } from './test-utils.js'; +import { type DevServer, type Fixture, loadFixture } from './test-utils.js'; // Helper to create encryption key from test key string -async function createKeyFromString(keyString) { +async function createKeyFromString(keyString: string) { const binaryString = atob(keyString); const bytes = new Uint8Array(binaryString.length); for (let i = 0; i < binaryString.length; i++) { @@ -30,8 +30,7 @@ async function getEncryptedComponentExport( describe('Server islands', () => { describe('SSR', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; + let fixture: Fixture; before(async () => { fixture = await loadFixture({ root: './fixtures/server-islands/ssr', @@ -43,7 +42,7 @@ describe('Server islands', () => { }); describe('dev', () => { - let devServer; + let devServer: DevServer; before(async () => { process.env.ASTRO_KEY = 'eKBaVEuI7YjfanEXHuJe/pwZKKt3LkAHeMxvTU7aR0M='; @@ -167,7 +166,7 @@ describe('Server islands', () => { const res = await fixture.fetch('/test'); assert.equal(res.status, 200); const html = await res.text(); - const fetchMatch = html.match(/fetch\('\/_server-islands\/Island\?[^']*p=([^&']*)/); + const fetchMatch = /fetch\('\/_server-islands\/Island\?[^']*p=([^&']*)/.exec(html)!; assert.equal(fetchMatch.length, 2, 'should include props in the query string'); assert.equal(fetchMatch[1], '', 'should not include encrypted empty props'); }); @@ -176,7 +175,7 @@ describe('Server islands', () => { const res = await fixture.fetch('/fragment'); assert.equal(res.status, 200); const html = await res.text(); - const fetchMatch = html.match(/fetch\('\/_server-islands\/Island\?[^']*p=([^&']*)/); + const fetchMatch = /fetch\('\/_server-islands\/Island\?[^']*p=([^&']*)/.exec(html)!; assert.equal(fetchMatch.length, 2, 'should include props in the query string'); assert.equal(fetchMatch[1], '', 'should not include encrypted empty props'); }); @@ -185,7 +184,7 @@ describe('Server islands', () => { const res = await fixture.fetch('/fragment'); assert.equal(res.status, 200); const html = await res.text(); - const fetchMatch = html.match(/fetch\('\/_server-islands\/Island\?[^']*p=([^&']*)/); + const fetchMatch = /fetch\('\/_server-islands\/Island\?[^']*p=([^&']*)/.exec(html)!; assert.equal(fetchMatch.length, 2, 'should include props in the query string'); assert.equal(fetchMatch[1], '', 'should not include encrypted empty props'); }); @@ -195,7 +194,7 @@ describe('Server islands', () => { assert.equal(res.status, 200); const html = await res.text(); // Extract the island fetch URL from the page - const urlMatch = html.match(/fetch\('(\/_server-islands\/Wrapper\?[^']+)'/); + const urlMatch = /fetch\('(\/_server-islands\/Wrapper\?[^']+)'/.exec(html)!; assert.ok(urlMatch, 'should have a server island fetch URL'); const islandRes = await fixture.fetch(urlMatch[1]); assert.equal(islandRes.status, 200); @@ -345,7 +344,7 @@ describe('Server islands', () => { const res = await app.render(request); assert.equal(res.status, 200); const html = await res.text(); - const fetchMatch = html.match(/fetch\('\/_server-islands\/Island\?[^']*p=([^&']*)/); + const fetchMatch = /fetch\('\/_server-islands\/Island\?[^']*p=([^&']*)/.exec(html)!; assert.equal(fetchMatch.length, 2, 'should include props in the query string'); assert.equal(fetchMatch[1], '', 'should not include encrypted empty props'); }); @@ -353,8 +352,7 @@ describe('Server islands', () => { }); describe('Hybrid mode', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; + let fixture: Fixture; before(async () => { fixture = await loadFixture({ root: './fixtures/server-islands/hybrid', @@ -384,7 +382,7 @@ describe('Server islands', () => { const $ = cheerio.load(html); const serverIslandScript = $('script').filter((_, el) => - $(el).html().trim().startsWith('async function replaceServerIsland'), + ($(el).html() ?? '').trim().startsWith('async function replaceServerIsland'), ); assert.equal( serverIslandScript.length, @@ -411,7 +409,7 @@ describe('Server islands', () => { const res = await devFixture.fetch('/'); assert.equal(res.status, 200); const html = await res.text(); - const fetchMatch = /fetch\('(\/_server-islands\/Island[^']*)/.exec(html); + const fetchMatch = /fetch\('(\/_server-islands\/Island[^']*)/.exec(html)!; assert.ok(fetchMatch, 'should have a server island fetch URL'); const islandRes = await devFixture.fetch(fetchMatch[1]); assert.equal( @@ -425,7 +423,7 @@ describe('Server islands', () => { }); describe('with no adapter', () => { - let devServer; + let devServer: DevServer; it('Errors during the build', async () => { try { @@ -434,7 +432,10 @@ describe('Server islands', () => { }); assert.equal(true, false, 'should not have succeeded'); } catch (err) { - assert.equal(err.title, 'Cannot use Server Islands without an adapter.'); + assert.equal( + (err as { title: string }).title, + 'Cannot use Server Islands without an adapter.', + ); } }); diff --git a/packages/astro/test/slots-preact.test.js b/packages/astro/test/slots-preact.test.ts similarity index 95% rename from packages/astro/test/slots-preact.test.js rename to packages/astro/test/slots-preact.test.ts index b486a27a777c..930f6181408f 100644 --- a/packages/astro/test/slots-preact.test.js +++ b/packages/astro/test/slots-preact.test.ts @@ -1,10 +1,10 @@ import assert from 'node:assert/strict'; import { before, describe, it } from 'node:test'; import * as cheerio from 'cheerio'; -import { loadFixture } from './test-utils.js'; +import { type Fixture, loadFixture } from './test-utils.js'; describe('Slots: Preact', () => { - let fixture; + let fixture: Fixture; before(async () => { fixture = await loadFixture({ root: './fixtures/slots-preact/' }); diff --git a/packages/astro/test/slots-react.test.js b/packages/astro/test/slots-react.test.ts similarity index 97% rename from packages/astro/test/slots-react.test.js rename to packages/astro/test/slots-react.test.ts index 64069dcef28a..5ae58d2e78b4 100644 --- a/packages/astro/test/slots-react.test.js +++ b/packages/astro/test/slots-react.test.ts @@ -1,10 +1,10 @@ import assert from 'node:assert/strict'; import { before, describe, it } from 'node:test'; import * as cheerio from 'cheerio'; -import { loadFixture } from './test-utils.js'; +import { type Fixture, loadFixture } from './test-utils.js'; describe('Slots: React', () => { - let fixture; + let fixture: Fixture; before(async () => { fixture = await loadFixture({ root: './fixtures/slots-react/' }); diff --git a/packages/astro/test/slots-solid.test.js b/packages/astro/test/slots-solid.test.ts similarity index 95% rename from packages/astro/test/slots-solid.test.js rename to packages/astro/test/slots-solid.test.ts index 68e64fe62214..a39317a975d8 100644 --- a/packages/astro/test/slots-solid.test.js +++ b/packages/astro/test/slots-solid.test.ts @@ -1,10 +1,10 @@ import assert from 'node:assert/strict'; import { before, describe, it } from 'node:test'; import * as cheerio from 'cheerio'; -import { loadFixture } from './test-utils.js'; +import { type Fixture, loadFixture } from './test-utils.js'; describe('Slots: Solid', () => { - let fixture; + let fixture: Fixture; before(async () => { fixture = await loadFixture({ root: './fixtures/slots-solid/' }); diff --git a/packages/astro/test/slots-svelte.test.js b/packages/astro/test/slots-svelte.test.ts similarity index 95% rename from packages/astro/test/slots-svelte.test.js rename to packages/astro/test/slots-svelte.test.ts index e45c6d414c37..6b3b1cce60ad 100644 --- a/packages/astro/test/slots-svelte.test.js +++ b/packages/astro/test/slots-svelte.test.ts @@ -1,10 +1,10 @@ import assert from 'node:assert/strict'; import { before, describe, it } from 'node:test'; import * as cheerio from 'cheerio'; -import { loadFixture } from './test-utils.js'; +import { type Fixture, loadFixture } from './test-utils.js'; describe('Slots: Svelte', () => { - let fixture; + let fixture: Fixture; before(async () => { fixture = await loadFixture({ root: './fixtures/slots-svelte/' }); diff --git a/packages/astro/test/slots-vue.test.js b/packages/astro/test/slots-vue.test.ts similarity index 95% rename from packages/astro/test/slots-vue.test.js rename to packages/astro/test/slots-vue.test.ts index 8edee824118c..1e3bb9e12dab 100644 --- a/packages/astro/test/slots-vue.test.js +++ b/packages/astro/test/slots-vue.test.ts @@ -1,10 +1,10 @@ import assert from 'node:assert/strict'; import { before, describe, it } from 'node:test'; import * as cheerio from 'cheerio'; -import { loadFixture } from './test-utils.js'; +import { type Fixture, loadFixture } from './test-utils.js'; describe('Slots: Vue', () => { - let fixture; + let fixture: Fixture; before(async () => { fixture = await loadFixture({ root: './fixtures/slots-vue/' }); diff --git a/packages/astro/test/sourcemap.test.js b/packages/astro/test/sourcemap.test.ts similarity index 82% rename from packages/astro/test/sourcemap.test.js rename to packages/astro/test/sourcemap.test.ts index 7040655a35df..3cc23fe81286 100644 --- a/packages/astro/test/sourcemap.test.js +++ b/packages/astro/test/sourcemap.test.ts @@ -1,9 +1,9 @@ import assert from 'node:assert/strict'; import { before, describe, it } from 'node:test'; -import { loadFixture } from './test-utils.js'; +import { type Fixture, loadFixture } from './test-utils.js'; describe('Sourcemap', async () => { - let fixture; + let fixture: Fixture; before(async () => { fixture = await loadFixture({ root: './fixtures/sourcemap/' }); @@ -12,7 +12,7 @@ describe('Sourcemap', async () => { it('Builds sourcemap', async () => { const dir = await fixture.readdir('./_astro'); - const counterMap = dir.find((file) => file.match(/^Counter\.[\w-]+\.js\.map$/)); + const counterMap = dir.find((file) => /^Counter\.[\w-]+\.js\.map$/.exec(file)); assert.ok(counterMap); }); diff --git a/packages/astro/test/space-in-folder-name.test.js b/packages/astro/test/space-in-folder-name.test.ts similarity index 84% rename from packages/astro/test/space-in-folder-name.test.js rename to packages/astro/test/space-in-folder-name.test.ts index 3de7ec13b72d..cfb5642bd8fd 100644 --- a/packages/astro/test/space-in-folder-name.test.js +++ b/packages/astro/test/space-in-folder-name.test.ts @@ -1,10 +1,10 @@ import assert from 'node:assert/strict'; import { after, before, describe, it } from 'node:test'; import * as cheerio from 'cheerio'; -import { loadFixture } from './test-utils.js'; +import { type DevServer, type Fixture, loadFixture } from './test-utils.js'; describe('Projects with a space in the folder name', () => { - let fixture; + let fixture: Fixture; before(async () => { fixture = await loadFixture({ @@ -13,8 +13,7 @@ describe('Projects with a space in the folder name', () => { }); describe('dev', () => { - /** @type {import('./test-utils').Fixture} */ - let devServer; + let devServer: DevServer; before(async () => { devServer = await fixture.startDevServer(); diff --git a/packages/astro/test/special-chars-in-component-imports.test.js b/packages/astro/test/special-chars-in-component-imports.test.ts similarity index 96% rename from packages/astro/test/special-chars-in-component-imports.test.js rename to packages/astro/test/special-chars-in-component-imports.test.ts index 33834b7d5d3a..6f6a80eb5245 100644 --- a/packages/astro/test/special-chars-in-component-imports.test.js +++ b/packages/astro/test/special-chars-in-component-imports.test.ts @@ -1,11 +1,10 @@ import assert from 'node:assert/strict'; import { after, before, describe, it } from 'node:test'; import { load as cheerioLoad } from 'cheerio'; -import { isWindows, loadFixture } from './test-utils.js'; +import { type DevServer, type Fixture, isWindows, loadFixture } from './test-utils.js'; describe('Special chars in component import paths', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; + let fixture: Fixture; const componentIds = [ 'caret', @@ -91,7 +90,7 @@ describe('Special chars in component import paths', () => { if (isWindows) return; describe('dev', () => { - let devServer; + let devServer: DevServer; before(async () => { devServer = await fixture.startDevServer(); diff --git a/packages/astro/test/static-build-code-component.test.js b/packages/astro/test/static-build-code-component.test.ts similarity index 86% rename from packages/astro/test/static-build-code-component.test.js rename to packages/astro/test/static-build-code-component.test.ts index d23d4115b229..8ba2c950c5d0 100644 --- a/packages/astro/test/static-build-code-component.test.js +++ b/packages/astro/test/static-build-code-component.test.ts @@ -1,10 +1,10 @@ import assert from 'node:assert/strict'; import { before, describe, it } from 'node:test'; import * as cheerio from 'cheerio'; -import { loadFixture } from './test-utils.js'; +import { type Fixture, loadFixture } from './test-utils.js'; describe('Code component inside static build', () => { - let fixture; + let fixture: Fixture; before(async () => { fixture = await loadFixture({ diff --git a/packages/astro/test/static-build-dir.test.js b/packages/astro/test/static-build-dir.test.ts similarity index 86% rename from packages/astro/test/static-build-dir.test.js rename to packages/astro/test/static-build-dir.test.ts index 1b99315a2597..f56ae9fe2005 100644 --- a/packages/astro/test/static-build-dir.test.js +++ b/packages/astro/test/static-build-dir.test.ts @@ -3,10 +3,8 @@ import { before, describe, it } from 'node:test'; import { loadFixture } from './test-utils.js'; describe('Static build: dir takes the URL path to the output directory', () => { - /** @type {URL} */ - let checkDir; - /** @type {URL} */ - let checkGeneratedDir; + let checkDir: URL; + let checkGeneratedDir: URL; before(async () => { const fixture = await loadFixture({ root: './fixtures/static-build-dir/', @@ -27,7 +25,7 @@ describe('Static build: dir takes the URL path to the output directory', () => { await fixture.build(); }); it('dir takes the URL path to the output directory', async () => { - const removeTrailingSlash = (str) => str.replace(/\/$/, ''); + const removeTrailingSlash = (str: string) => str.replace(/\/$/, ''); assert.equal( removeTrailingSlash(checkDir.toString()), removeTrailingSlash(new URL('./fixtures/static-build-dir/dist', import.meta.url).toString()), diff --git a/packages/astro/test/static-build-frameworks.test.js b/packages/astro/test/static-build-frameworks.test.ts similarity index 92% rename from packages/astro/test/static-build-frameworks.test.js rename to packages/astro/test/static-build-frameworks.test.ts index ed362b7c28cb..ddc425d0dead 100644 --- a/packages/astro/test/static-build-frameworks.test.js +++ b/packages/astro/test/static-build-frameworks.test.ts @@ -1,14 +1,14 @@ import assert from 'node:assert/strict'; import { before, describe, it } from 'node:test'; import * as cheerio from 'cheerio'; -import { isWindows, loadFixture } from './test-utils.js'; +import { type Fixture, isWindows, loadFixture } from './test-utils.js'; describe('Static build - frameworks', () => { if (isWindows) { return; } - let fixture; + let fixture: Fixture; before(async () => { fixture = await loadFixture({ diff --git a/packages/astro/test/static-build-page-dist-url.test.js b/packages/astro/test/static-build-page-dist-url.test.ts similarity index 91% rename from packages/astro/test/static-build-page-dist-url.test.js rename to packages/astro/test/static-build-page-dist-url.test.ts index 4ebd9b5d327e..2f74e1d4038d 100644 --- a/packages/astro/test/static-build-page-dist-url.test.js +++ b/packages/astro/test/static-build-page-dist-url.test.ts @@ -3,10 +3,8 @@ import { before, describe, it } from 'node:test'; import { loadFixture } from './test-utils.js'; describe('Static build: pages routes have distURL', () => { - /** @type {Map} */ - let assets; + let assets: Map; before(async () => { - /** @type {import('./test-utils').Fixture} */ const fixture = await loadFixture({ root: './fixtures/astro pages/', integrations: [ diff --git a/packages/astro/test/static-build-page-url-format.test.js b/packages/astro/test/static-build-page-url-format.test.ts similarity index 87% rename from packages/astro/test/static-build-page-url-format.test.js rename to packages/astro/test/static-build-page-url-format.test.ts index 2755b3ffb3cb..5351c06346f4 100644 --- a/packages/astro/test/static-build-page-url-format.test.js +++ b/packages/astro/test/static-build-page-url-format.test.ts @@ -1,9 +1,9 @@ import assert from 'node:assert/strict'; import { before, describe, it } from 'node:test'; -import { loadFixture } from './test-utils.js'; +import { type Fixture, loadFixture } from './test-utils.js'; describe("Static build - format: 'file'", () => { - let fixture; + let fixture: Fixture; before(async () => { fixture = await loadFixture({ diff --git a/packages/astro/test/static-build-vite-plugins.test.js b/packages/astro/test/static-build-vite-plugins.test.ts similarity index 92% rename from packages/astro/test/static-build-vite-plugins.test.js rename to packages/astro/test/static-build-vite-plugins.test.ts index 23a801ee9639..05fda88c7daf 100644 --- a/packages/astro/test/static-build-vite-plugins.test.js +++ b/packages/astro/test/static-build-vite-plugins.test.ts @@ -3,10 +3,8 @@ import { before, describe, it } from 'node:test'; import { loadFixture } from './test-utils.js'; describe('Static build: vite plugins included when required', () => { - /** @type {Map} */ - const pluginsCalled = new Map(); - /** @type {Map} */ - const expectedPluginResult = new Map([ + const pluginsCalled = new Map(); + const expectedPluginResult = new Map([ ['prepare-no-apply-plugin', true], ['prepare-serve-plugin', false], ['prepare-apply-fn-plugin', true], @@ -14,7 +12,6 @@ describe('Static build: vite plugins included when required', () => { ['prepare-build-plugin', true], ]); before(async () => { - /** @type {import('./test-utils').Fixture} */ const fixture = await loadFixture({ root: './fixtures/astro pages/', integrations: [ diff --git a/packages/astro/test/svg-deduplication.test.js b/packages/astro/test/svg-deduplication.test.ts similarity index 94% rename from packages/astro/test/svg-deduplication.test.js rename to packages/astro/test/svg-deduplication.test.ts index a3e69dfa3343..c52581e0c508 100644 --- a/packages/astro/test/svg-deduplication.test.js +++ b/packages/astro/test/svg-deduplication.test.ts @@ -2,11 +2,10 @@ import assert from 'node:assert/strict'; import { readdir } from 'node:fs/promises'; import { after, before, describe, it } from 'node:test'; import * as cheerio from 'cheerio'; -import { loadFixture } from './test-utils.js'; +import { type DevServer, type Fixture, loadFixture } from './test-utils.js'; describe('SVG Deduplication', () => { - /** @type {import('./test-utils').Fixture} */ - let fixture; + let fixture: Fixture; describe('build', () => { before(async () => { @@ -21,7 +20,7 @@ describe('SVG Deduplication', () => { const distDir = new URL('./fixtures/svg-deduplication/dist/', import.meta.url); const assetsDir = new URL('./_astro/', distDir); - let svgFiles = []; + let svgFiles: string[] = []; try { const files = await readdir(assetsDir); svgFiles = files.filter((file) => file.endsWith('.svg')); @@ -73,8 +72,7 @@ describe('SVG Deduplication', () => { }); describe('dev', () => { - /** @type {import('./test-utils').DevServer} */ - let devServer; + let devServer: DevServer; before(async () => { fixture = await loadFixture({