Skip to content

Commit

Permalink
get type setup in order for app
Browse files Browse the repository at this point in the history
  • Loading branch information
frontendphil committed Jan 8, 2025
1 parent ec59a90 commit 1e76155
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 26 deletions.
2 changes: 1 addition & 1 deletion deployables/app/app/routes/edit-route.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('Edit route', () => {
it('shows the name of a route', async () => {
const route = createMockExecutionRoute({ label: 'Test route' })

await render(
await render<typeof import('./edit-route')>(
'/edit-route',
{ path: '/edit-route', Component: EditRoute, loader },
{ searchParams: { route: btoa(JSON.stringify(route)) } },
Expand Down
6 changes: 3 additions & 3 deletions deployables/app/test-utils/render.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {
FrameworkRoute,
renderFramework,
RenderOptions,
RouteModule,
type FrameworkRoute,
type RenderOptions,
type RouteModule,
} from '@zodiac/test-utils'

export function render<Module extends RouteModule>(
Expand Down
11 changes: 5 additions & 6 deletions deployables/app/tsconfig.cloudflare.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,23 @@
"extends": "./tsconfig.json",
"include": [
".react-router/types/**/*",
"vitest.setup.ts",
"app/**/*",
"app/**/.server/**/*",
"app/**/.client/**/*",
"workers/**/*"
"workers/**/*",
"test-utils/**/*"
],
"compilerOptions": {
"composite": true,
"strict": true,
"lib": ["DOM", "DOM.Iterable", "ES2022"],
"types": ["@cloudflare/workers-types", "vite/client"],
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "bundler",
"jsx": "react-jsx",
"baseUrl": ".",
"rootDirs": [".", "./.react-router/types"],
"paths": {
"~/*": ["./app/*"]
"~/*": ["./app/*"],
"@/test-utils": ["./test-utils/index.ts"]
},
"esModuleInterop": true,
"resolveJsonModule": true
Expand Down
7 changes: 4 additions & 3 deletions deployables/app/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
{ "path": "./tsconfig.cloudflare.json" }
],
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"checkJs": true,
"verbatimModuleSyntax": true,
"skipLibCheck": true,
"strict": true,
"noEmit": true,
"paths": {
"@/test-utils": ["./test-utils/index.ts"]
}
"moduleResolution": "bundler",
"types": ["@testing-library/jest-dom"]
}
}
9 changes: 4 additions & 5 deletions deployables/app/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
{
"extends": "./tsconfig.json",
"include": ["tailwind.config.ts", "vite.config.ts", "vitest.setup.mts"],
"include": ["tailwind.config.ts", "vite.config.ts", "vitest.setup.ts"],
"compilerOptions": {
"composite": true,
"strict": true,
"types": ["node"],
"lib": ["ES2022"],
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "bundler"
"paths": {
"@/test-utils": ["./test-utils/index.ts"]
}
}
}
4 changes: 2 additions & 2 deletions deployables/app/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { fileURLToPath } from 'url'
import { defineConfig } from 'vitest/config'
import tsConfig from './tsconfig.json'
import tsConfig from './tsconfig.node.json'

const alias = Object.entries(tsConfig.compilerOptions.paths).reduce(
(result, [key, value]) => ({
Expand All @@ -18,7 +18,7 @@ export default defineConfig({
test: {
alias,
environment: 'happy-dom',
setupFiles: ['./vitest.setup.mts'],
setupFiles: ['./vitest.setup.ts'],
include: ['./app/**/*.{spec,test}.{ts,tsx}'],
mockReset: true,
clearMocks: true,
Expand Down
File renamed without changes.
23 changes: 17 additions & 6 deletions packages/test-utils/src/renderFramework.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from '@testing-library/react'
import { render, type RenderResult } from '@testing-library/react'
import type { ComponentType } from 'react'
import { createRoutesStub, useLoaderData, useParams } from 'react-router'
import type {
Expand Down Expand Up @@ -29,10 +29,21 @@ export type RouteModule = {
}

type Info<Module extends RouteModule> = {
parents: []
id: 'routes/test-route'
file: 'routes/test-route-not-real.tsx'
path: '/test-route-not-real'
parents: [
{
parents: []
id: 'root'
file: 'root.tsx'
path: ''
params: {} & { [key: string]: string | undefined }
module: Module
loaderData: CreateLoaderData<{}>
actionData: CreateActionData<{}>
},
]
id: any
file: any
path: any
params: {} & { [key: string]: string | undefined }
module: Module
loaderData: CreateLoaderData<Module>
Expand All @@ -54,7 +65,7 @@ export async function renderFramework<Module extends RouteModule>(
currentPath: string,
route: FrameworkRoute<Module>,
{ inspectRoutes = [], ...options }: RenderOptions,
) {
): Promise<RenderResult> {
const Stub = createRoutesStub([
{
path: '/',
Expand Down

0 comments on commit 1e76155

Please sign in to comment.