Skip to content
Open
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
20 changes: 20 additions & 0 deletions e2e/react-start/encoding/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
node_modules
package-lock.json
yarn.lock

.DS_Store
.cache
.env
.vercel
.output

/build/
/api/
/server/build
/public/build
# Sentry Config File
.env.sentry-build-plugin
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
4 changes: 4 additions & 0 deletions e2e/react-start/encoding/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
**/build
**/public
pnpm-lock.yaml
routeTree.gen.ts
38 changes: 38 additions & 0 deletions e2e/react-start/encoding/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "tanstack-react-start-e2e-encoding",
"private": true,
"sideEffects": false,
"type": "module",
"scripts": {
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
"start": "node .output/server/index.mjs",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
Comment on lines +6 to +12
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Make test cleanup cross‑platform.
rm -rf breaks on Windows runners. Use rimraf.

Apply:

   "scripts": {
     "dev": "vite dev --port 3000",
     "dev:e2e": "vite dev",
     "build": "vite build && tsc --noEmit",
     "start": "node .output/server/index.mjs",
-    "test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
+    "test:e2e": "rimraf port*.txt && playwright test --project=chromium"
   },

And add devDependency:

   "devDependencies": {
+    "rimraf": "^6.0.0",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"scripts": {
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
"start": "node .output/server/index.mjs",
"test:e2e": "rm -rf port*.txt; playwright test --project=chromium"
},
"scripts": {
"dev": "vite dev --port 3000",
"dev:e2e": "vite dev",
"build": "vite build && tsc --noEmit",
"start": "node .output/server/index.mjs",
"test:e2e": "rimraf port*.txt && playwright test --project=chromium"
},
"devDependencies": {
"rimraf": "^6.0.0"
}
🤖 Prompt for AI Agents
In e2e/react-start/encoding/package.json around lines 6 to 12, the test:e2e
script uses "rm -rf port*.txt" which fails on Windows; replace that removal with
a cross-platform tool: add rimraf as a devDependency (npm i -D rimraf or yarn
add -D rimraf) and update the "test:e2e" script to invoke rimraf to delete
port*.txt (e.g. use rimraf port*.txt && playwright test --project=chromium) so
cleanup works on all CI runners.

"dependencies": {
"@tanstack/react-router": "workspace:^",
"@tanstack/react-router-devtools": "workspace:^",
"@tanstack/react-start": "workspace:^",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"redaxios": "^0.5.1",
"tailwind-merge": "^2.6.0",
"vite": "6.3.5",
"zod": "^3.24.2"
},
"devDependencies": {
"@playwright/test": "^1.50.1",
"@tanstack/router-e2e-utils": "workspace:^",
"@types/node": "^22.10.2",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@vitejs/plugin-react": "^4.3.4",
"autoprefixer": "^10.4.20",
"combinate": "^1.1.11",
"postcss": "^8.5.1",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.2",
"vite-tsconfig-paths": "^5.1.4"
}
}
42 changes: 42 additions & 0 deletions e2e/react-start/encoding/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { defineConfig, devices } from '@playwright/test'
import {
getDummyServerPort,
getTestServerPort,
} from '@tanstack/router-e2e-utils'
import packageJson from './package.json' with { type: 'json' }

const PORT = await getTestServerPort(packageJson.name)
const EXTERNAL_PORT = await getDummyServerPort(packageJson.name)
const baseURL = `http://localhost:${PORT}`

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
workers: 1,

reporter: [['line']],

globalSetup: './tests/setup/global.setup.ts',
globalTeardown: './tests/setup/global.teardown.ts',

use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL,
},

webServer: {
command: `VITE_NODE_ENV="test" VITE_EXTERNAL_PORT=${EXTERNAL_PORT} pnpm build && VITE_NODE_ENV="test" VITE_EXTERNAL_PORT=${EXTERNAL_PORT} VITE_SERVER_PORT=${PORT} PORT=${PORT} pnpm start`,
url: baseURL,
reuseExistingServer: !process.env.CI,
stdout: 'pipe',
},

projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
})
6 changes: 6 additions & 0 deletions e2e/react-start/encoding/postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
19 changes: 19 additions & 0 deletions e2e/react-start/encoding/src/client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// DO NOT DELETE THIS FILE!!!
// This file is a good smoke test to make sure the custom client entry is working
import { StrictMode, startTransition } from 'react'
import { hydrateRoot } from 'react-dom/client'
import { StartClient } from '@tanstack/react-start'
import { createRouter } from './router'

console.log("[client-entry]: using custom client entry in 'src/client.tsx'")

const router = createRouter()

startTransition(() => {
hydrateRoot(
document,
<StrictMode>
<StartClient router={router} />
</StrictMode>,
)
})
10 changes: 10 additions & 0 deletions e2e/react-start/encoding/src/components/CustomMessage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import * as React from 'react'

export function CustomMessage({ message }: { message: string }) {
return (
<div className="py-2">
<div className="italic">This is a custom message:</div>
<p>{message}</p>
</div>
)
}
53 changes: 53 additions & 0 deletions e2e/react-start/encoding/src/components/DefaultCatchBoundary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import {
ErrorComponent,
Link,
rootRouteId,
useMatch,
useRouter,
} from '@tanstack/react-router'
import type { ErrorComponentProps } from '@tanstack/react-router'

export function DefaultCatchBoundary({ error }: ErrorComponentProps) {
const router = useRouter()
const isRoot = useMatch({
strict: false,
select: (state) => state.id === rootRouteId,
})

console.error(error)

return (
<div className="min-w-0 flex-1 p-4 flex flex-col items-center justify-center gap-6">
<ErrorComponent error={error} />
<div className="flex gap-2 items-center flex-wrap">
<button
onClick={() => {
router.invalidate()
}}
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
>
Try Again
</button>
{isRoot ? (
<Link
to="/"
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
>
Home
</Link>
) : (
<Link
to="/"
className={`px-2 py-1 bg-gray-600 dark:bg-gray-700 rounded text-white uppercase font-extrabold`}
onClick={(e) => {
e.preventDefault()
window.history.back()
}}
>
Go Back
</Link>
)}
</div>
</div>
)
}
25 changes: 25 additions & 0 deletions e2e/react-start/encoding/src/components/NotFound.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Link } from '@tanstack/react-router'

export function NotFound({ children }: { children?: any }) {
return (
<div className="space-y-2 p-2" data-testid="default-not-found-component">
<div className="text-gray-600 dark:text-gray-400">
{children || <p>The page you are looking for does not exist.</p>}
</div>
<p className="flex items-center gap-2 flex-wrap">
<button
onClick={() => window.history.back()}
className="bg-emerald-500 text-white px-2 py-1 rounded uppercase font-black text-sm"
>
Go back
</button>
<Link
to="/"
className="bg-cyan-600 text-white px-2 py-1 rounded uppercase font-black text-sm"
>
Start Over
</Link>
</p>
</div>
)
}
153 changes: 153 additions & 0 deletions e2e/react-start/encoding/src/routeTree.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
/* eslint-disable */

// @ts-nocheck

// noinspection JSUnusedGlobalSymbols

// This file was automatically generated by TanStack Router.
// You should NOT make any changes in this file as it will be overwritten.
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.

import type { CreateFileRoute, FileRoutesByPath } from '@tanstack/react-router'
import type {
CreateServerFileRoute,
ServerFileRoutesByPath,
} from '@tanstack/react-start/server'

import { Route as rootRouteImport } from './routes/__root'
import { Route as NoCharsetRouteImport } from './routes/no-charset'
import { Route as CharsetRouteImport } from './routes/charset'
import { Route as IndexRouteImport } from './routes/index'

const NoCharsetRoute = NoCharsetRouteImport.update({
id: '/no-charset',
path: '/no-charset',
getParentRoute: () => rootRouteImport,
} as any)
const CharsetRoute = CharsetRouteImport.update({
id: '/charset',
path: '/charset',
getParentRoute: () => rootRouteImport,
} as any)
const IndexRoute = IndexRouteImport.update({
id: '/',
path: '/',
getParentRoute: () => rootRouteImport,
} as any)

export interface FileRoutesByFullPath {
'/': typeof IndexRoute
'/charset': typeof CharsetRoute
'/no-charset': typeof NoCharsetRoute
}
export interface FileRoutesByTo {
'/': typeof IndexRoute
'/charset': typeof CharsetRoute
'/no-charset': typeof NoCharsetRoute
}
export interface FileRoutesById {
__root__: typeof rootRouteImport
'/': typeof IndexRoute
'/charset': typeof CharsetRoute
'/no-charset': typeof NoCharsetRoute
}
export interface FileRouteTypes {
fileRoutesByFullPath: FileRoutesByFullPath
fullPaths: '/' | '/charset' | '/no-charset'
fileRoutesByTo: FileRoutesByTo
to: '/' | '/charset' | '/no-charset'
id: '__root__' | '/' | '/charset' | '/no-charset'
fileRoutesById: FileRoutesById
}
export interface RootRouteChildren {
IndexRoute: typeof IndexRoute
CharsetRoute: typeof CharsetRoute
NoCharsetRoute: typeof NoCharsetRoute
}

declare module '@tanstack/react-router' {
interface FileRoutesByPath {
'/': {
id: '/'
path: '/'
fullPath: '/'
preLoaderRoute: typeof IndexRouteImport
parentRoute: typeof rootRouteImport
}
'/charset': {
id: '/charset'
path: '/charset'
fullPath: '/charset'
preLoaderRoute: typeof CharsetRouteImport
parentRoute: typeof rootRouteImport
}
'/no-charset': {
id: '/no-charset'
path: '/no-charset'
fullPath: '/no-charset'
preLoaderRoute: typeof NoCharsetRouteImport
parentRoute: typeof rootRouteImport
}
}
}

declare module './routes/index' {
const createFileRoute: CreateFileRoute<
'/',
FileRoutesByPath['/']['parentRoute'],
FileRoutesByPath['/']['id'],
FileRoutesByPath['/']['path'],
FileRoutesByPath['/']['fullPath']
>

const createServerFileRoute: CreateServerFileRoute<
ServerFileRoutesByPath['/']['parentRoute'],
ServerFileRoutesByPath['/']['id'],
ServerFileRoutesByPath['/']['path'],
ServerFileRoutesByPath['/']['fullPath'],
unknown
>
}
declare module './routes/charset' {
const createFileRoute: CreateFileRoute<
'/charset',
FileRoutesByPath['/charset']['parentRoute'],
FileRoutesByPath['/charset']['id'],
FileRoutesByPath['/charset']['path'],
FileRoutesByPath['/charset']['fullPath']
>

const createServerFileRoute: CreateServerFileRoute<
ServerFileRoutesByPath['/charset']['parentRoute'],
ServerFileRoutesByPath['/charset']['id'],
ServerFileRoutesByPath['/charset']['path'],
ServerFileRoutesByPath['/charset']['fullPath'],
unknown
>
}
declare module './routes/no-charset' {
const createFileRoute: CreateFileRoute<
'/no-charset',
FileRoutesByPath['/no-charset']['parentRoute'],
FileRoutesByPath['/no-charset']['id'],
FileRoutesByPath['/no-charset']['path'],
FileRoutesByPath['/no-charset']['fullPath']
>

const createServerFileRoute: CreateServerFileRoute<
ServerFileRoutesByPath['/no-charset']['parentRoute'],
ServerFileRoutesByPath['/no-charset']['id'],
ServerFileRoutesByPath['/no-charset']['path'],
ServerFileRoutesByPath['/no-charset']['fullPath'],
unknown
>
}

const rootRouteChildren: RootRouteChildren = {
IndexRoute: IndexRoute,
CharsetRoute: CharsetRoute,
NoCharsetRoute: NoCharsetRoute,
}
export const routeTree = rootRouteImport
._addFileChildren(rootRouteChildren)
._addFileTypes<FileRouteTypes>()
Loading