-
Notifications
You must be signed in to change notification settings - Fork 331
/
Copy pathnext-build.test.ts
72 lines (61 loc) · 1.9 KB
/
next-build.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { expect, test } from '@playwright/test';
import type { Application } from '../models/application';
import { appConfigs } from '../presets';
test.describe('next build @nextjs', () => {
test.describe.configure({ mode: 'parallel' });
let app: Application;
const output = [];
test.beforeAll(async () => {
app = await appConfigs.next.appRouter
.clone()
.addFile(
'src/app/provider.tsx',
() => `'use client'
import { ClerkProvider } from "@clerk/nextjs"
export function Provider({ children }: { children: any }) {
return (
<ClerkProvider>
{children}
</ClerkProvider>
)
}`,
)
.addFile(
'src/app/layout.tsx',
() => `import './globals.css';
import { Inter } from 'next/font/google';
import { Provider } from './provider';
const inter = Inter({ subsets: ['latin'] });
export const metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
};
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<Provider>
<html lang='en'>
<body className={inter.className}>{children}</body>
</html>
</Provider>
);
}
`,
)
.commit();
await app.setup();
await app.withEnv(appConfigs.envs.withEmailCodes);
await app.build();
});
test.afterAll(async () => {
await app.teardown();
});
test('When <ClerkProvider /> is used as a client component, builds successfully and does not force dynamic rendering', () => {
const dynamicIndicator = 'λ';
/**
* Using /_not-found as it is an internal page that should statically render by default.
* This is a good indicator of whether or not the entire app has been opted-in to dynamic rendering.
*/
const notFoundPageLine = app.buildOutput.split('\n').find(msg => msg.includes('/_not-found'));
expect(notFoundPageLine).not.toContain(dynamicIndicator);
});
});