Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/integrations/alpinejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"build": "astro-scripts build \"src/**/*.ts\" && tsc",
"build:ci": "astro-scripts build \"src/**/*.ts\"",
"dev": "astro-scripts dev \"src/**/*.ts\"",
"test:e2e": "playwright test"
"test:e2e": "playwright test",
"typecheck:tests": "tsc --build tsconfig.test.json"
},
"peerDependencies": {
"@types/alpinejs": "^3.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import fs from 'node:fs/promises';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { test as testBase } from '@playwright/test';
import { loadFixture as baseLoadFixture } from '../../../astro/test/test-utils.js';
import {
loadFixture as baseLoadFixture,
type Fixture,
type AstroInlineConfig,
type DevServer,
} from '../../../astro/test/test-utils.js';

// Get all test files in directory, assign unique port for each of them so they don't conflict
const testFiles = await fs.readdir(new URL('.', import.meta.url));
Expand All @@ -14,7 +19,7 @@ for (let i = 0; i < testFiles.length; i++) {
}
}

function loadFixture(inlineConfig) {
function loadFixture(inlineConfig: AstroInlineConfig) {
if (!inlineConfig?.root) throw new Error("Must provide { root: './fixtures/...' }");

// resolve the relative root (i.e. "./fixtures/tailwindcss") to a full filepath
Expand All @@ -23,15 +28,15 @@ function loadFixture(inlineConfig) {
...inlineConfig,
root: fileURLToPath(new URL(inlineConfig.root, import.meta.url)),
server: {
port: testFileToPort.get(path.basename(inlineConfig.root)),
port: testFileToPort.get(path.basename(String(inlineConfig.root))),
},
});
}

function testFactory(inlineConfig) {
let fixture;
function testFactory(inlineConfig: AstroInlineConfig) {
let fixture: Fixture;

const test = testBase.extend({
const test = testBase.extend<{ astro: Fixture }>({
// biome-ignore lint/correctness/noEmptyPattern: playwright needs this
astro: async ({}, use) => {
fixture = fixture || (await loadFixture(inlineConfig));
Expand All @@ -46,10 +51,10 @@ function testFactory(inlineConfig) {
return test;
}

export function prepareTestFactory(opts) {
export function prepareTestFactory(opts: AstroInlineConfig) {
const test = testFactory(opts);

let devServer;
let devServer: DevServer;

test.beforeAll(async ({ astro }) => {
devServer = await astro.startDevServer();
Expand Down
17 changes: 17 additions & 0 deletions packages/integrations/alpinejs/tsconfig.test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"extends": "../../../tsconfig.base.json",
"include": ["test/**/*.ts"],
"exclude": ["test/fixtures/**"],
"compilerOptions": {
"noEmit": true,
"allowJs": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"rewriteRelativeImportExtensions": true
},
"references": [
{
"path": "../../astro/tsconfig.test.json"
}
]
}
Loading