Skip to content

Commit f8a230f

Browse files
authored
test(e2e): Add integration tests for Fastify (#8061)
1 parent d32bf2c commit f8a230f

16 files changed

Lines changed: 332 additions & 0 deletions

File tree

.changeset/three-cameras-decide.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ jobs:
292292
[
293293
"generic",
294294
"express",
295+
"fastify",
295296
"ap-flows",
296297
"localhost",
297298
"sessions",

integration/presets/fastify.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { applicationConfig } from '../models/applicationConfig';
2+
import { templates } from '../templates';
3+
import { PKGLAB } from './utils';
4+
5+
const vite = applicationConfig()
6+
.setName('fastify-vite')
7+
.useTemplate(templates['fastify-vite'])
8+
.setEnvFormatter('public', key => `VITE_${key}`)
9+
.addScript('setup', 'pnpm install')
10+
.addScript('dev', 'pnpm dev')
11+
.addScript('build', 'pnpm build')
12+
.addScript('serve', 'pnpm start')
13+
.addDependency('@clerk/fastify', PKGLAB)
14+
.addDependency('@clerk/clerk-js', PKGLAB)
15+
.addDependency('@clerk/ui', PKGLAB);
16+
17+
export const fastify = {
18+
vite,
19+
} as const;

integration/presets/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { customFlows } from './custom-flows';
33
import { envs, instanceKeys } from './envs';
44
import { expo } from './expo';
55
import { express } from './express';
6+
import { fastify } from './fastify';
67
import { hono } from './hono';
78
import { createLongRunningApps } from './longRunningApps';
89
import { next } from './next';
@@ -16,6 +17,7 @@ export const appConfigs = {
1617
customFlows,
1718
envs,
1819
express,
20+
fastify,
1921
hono,
2022
longRunningApps: createLongRunningApps(),
2123
next,

integration/presets/longRunningApps.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { astro } from './astro';
44
import { envs } from './envs';
55
import { expo } from './expo';
66
import { express } from './express';
7+
import { fastify } from './fastify';
78
import { hono } from './hono';
89
import { next } from './next';
910
import { nuxt } from './nuxt';
@@ -82,6 +83,12 @@ export const createLongRunningApps = () => {
8283
{ id: 'react-router.node', config: reactRouter.reactRouterNode, env: envs.withEmailCodes },
8384
{ id: 'express.vite.withEmailCodes', config: express.vite, env: envs.withEmailCodes },
8485

86+
/**
87+
* Fastify apps
88+
*/
89+
{ id: 'fastify.vite.withEmailCodes', config: fastify.vite, env: envs.withEmailCodes },
90+
{ id: 'fastify.vite.withEmailCodesProxy', config: fastify.vite, env: envs.withEmailCodesProxy },
91+
8592
/**
8693
* Hono apps
8794
*/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + TS + Fastify</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script type="module" src="/src/client/main.ts"></script>
12+
</body>
13+
</html>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "fastify-vite",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"build": "vite build",
7+
"dev": "PORT=$PORT tsx src/server/main.ts",
8+
"preview": "vite preview --port $PORT --no-open",
9+
"start": "PORT=$PORT NODE_ENV=production tsx src/server/main.ts"
10+
},
11+
"dependencies": {
12+
"dotenv": "^17.2.1",
13+
"express": "^5.1.0",
14+
"fastify": "^5.7.2",
15+
"fastify-plugin": "^5.0.1",
16+
"tsx": "^4.20.3",
17+
"vite-express": "^0.21.1"
18+
},
19+
"devDependencies": {
20+
"@types/express": "^5.0.3",
21+
"@types/node": "^24.2.1",
22+
"typescript": "^5.8.3",
23+
"vite": "^6.3.3"
24+
}
25+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Clerk } from '@clerk/clerk-js';
2+
import { ClerkUI } from '@clerk/ui/entry';
3+
4+
const publishableKey = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY;
5+
6+
document.addEventListener('DOMContentLoaded', async function () {
7+
const clerk = new Clerk(publishableKey);
8+
9+
await clerk.load({
10+
ui: { ClerkUI },
11+
});
12+
13+
if (clerk.isSignedIn) {
14+
document.getElementById('app')!.innerHTML = `
15+
<div id="user-button"></div>
16+
`;
17+
18+
const userButtonDiv = document.getElementById('user-button');
19+
20+
clerk.mountUserButton(userButtonDiv);
21+
} else {
22+
document.getElementById('app')!.innerHTML = `
23+
<div id="sign-in"></div>
24+
`;
25+
26+
const signInDiv = document.getElementById('sign-in');
27+
28+
clerk.mountSignIn(signInDiv);
29+
}
30+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"module": "ESNext",
5+
"moduleResolution": "Bundler"
6+
}
7+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="vite/client" />

0 commit comments

Comments
 (0)