Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add next-types-plugin test #70162

Merged
merged 5 commits into from
Sep 17, 2024
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { ReactNode } from 'react'
export default function Layout({ children }: { children: ReactNode }) {
return <div>{children}</div>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <p>hello world</p>
}
8 changes: 8 additions & 0 deletions test/production/app-dir/next-types-plugin/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { ReactNode } from 'react'
export default function Root({ children }: { children: ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { ReactNode } from 'react'
export default function Layout({ children }: { children: ReactNode }) {
return <div>{children}</div>
}
3 changes: 3 additions & 0 deletions test/production/app-dir/next-types-plugin/app/nested/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <p>hello world</p>
}
3 changes: 3 additions & 0 deletions test/production/app-dir/next-types-plugin/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <p>hello world</p>
}
34 changes: 34 additions & 0 deletions test/production/app-dir/next-types-plugin/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { nextTestSetup } from 'e2e-utils'
;(process.env.TURBOPACK ? describe.skip : describe)('next-types-plugin', () => {
const { next, skipped } = nextTestSetup({
files: __dirname,
skipDeployment: true,
})

if (skipped) return

it('should have type for root page', async () => {
expect(await next.hasFile('app/page.tsx')).toBe(true)
expect(await next.hasFile('.next/types/app/page.ts')).toBe(true)
})
it('should have type for root layout', async () => {
expect(await next.hasFile('app/layout.tsx')).toBe(true)
expect(await next.hasFile('.next/types/app/layout.ts')).toBe(true)
})
it('should have type for nested page', async () => {
expect(await next.hasFile('app/nested/page.tsx')).toBe(true)
expect(await next.hasFile('.next/types/app/nested/page.ts')).toBe(true)
})
it('should have type for nested layout', async () => {
expect(await next.hasFile('app/nested/layout.tsx')).toBe(true)
expect(await next.hasFile('.next/types/app/nested/layout.ts')).toBe(true)
})
it('should have type for dynamic page', async () => {
expect(await next.hasFile('app/[dynamic]/page.tsx')).toBe(true)
expect(await next.hasFile('.next/types/app/[dynamic]/page.ts')).toBe(true)
})
it('should have type for dynamic layout', async () => {
expect(await next.hasFile('app/[dynamic]/layout.tsx')).toBe(true)
expect(await next.hasFile('.next/types/app/[dynamic]/layout.ts')).toBe(true)
})
})
6 changes: 6 additions & 0 deletions test/production/app-dir/next-types-plugin/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {}

module.exports = nextConfig
Loading