-
-
Notifications
You must be signed in to change notification settings - Fork 242
Expand file tree
/
Copy patherror.test.ts
More file actions
57 lines (52 loc) · 1.53 KB
/
error.test.ts
File metadata and controls
57 lines (52 loc) · 1.53 KB
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
import { test, expect } from '@playwright/test'
import { x } from 'tinyexec'
import { setupInlineFixture } from './fixture'
test.describe('invalid directives', () => {
test.describe('"use server" in "use client"', () => {
const root = 'examples/e2e/temp/use-server-in-use-client'
test.beforeAll(async () => {
await setupInlineFixture({
src: 'examples/starter',
dest: root,
files: {
'src/client.tsx': /* tsx */ `
"use client";
export function TestClient() {
return <div>[test-client]</div>
}
function testFn() {
"use server";
console.log("testFn");
}
`,
'src/root.tsx': /* tsx */ `
import { TestClient } from './client.tsx'
export function Root() {
return (
<html lang="en">
<head>
<meta charSet="UTF-8" />
</head>
<body>
<div>[test-server]</div>
<TestClient />
</body>
</html>
)
}
`,
},
})
})
test('build', async () => {
const result = await x('pnpm', ['build'], {
throwOnError: false,
nodeOptions: { cwd: root },
})
expect(result.stderr).toContain(
`'use server' directive is not allowed inside 'use client'`,
)
expect(result.exitCode).not.toBe(0)
})
})
})