-
Notifications
You must be signed in to change notification settings - Fork 417
Expand file tree
/
Copy pathserver-function.test.ts
More file actions
84 lines (71 loc) · 3.73 KB
/
server-function.test.ts
File metadata and controls
84 lines (71 loc) · 3.73 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import { expect, test } from "@playwright/test";
test.describe("server-function", () => {
test("should have isServer true in the server function - nested", async ({ page }) => {
await page.goto("http://localhost:3000/is-server-nested");
await expect(page.locator("#server-fn-test")).toContainText('{"serverFnWithIsServer":true}');
});
test("should have isServer true in the server function - const", async ({ page }) => {
await page.goto("http://localhost:3000/is-server-const");
await expect(page.locator("#server-fn-test")).toContainText('{"serverFnWithIsServer":true}');
});
test("should have an id of type string in the server function meta - nested", async ({
page,
}) => {
await page.goto("http://localhost:3000/server-function-meta-nested");
await expect(page.locator("#server-fn-test")).toContainText('{"serverFnWithMeta":"string"}');
});
test("should externalize node builtin in server function - nested", async ({ page }) => {
await page.goto("http://localhost:3000/node-builtin-nested");
await expect(page.locator("#server-fn-test")).toContainText(
'{"serverFnWithNodeBuiltin":"can/externalize"}',
);
});
test("should externalize npm module in server function - nested", async ({ page }) => {
await page.goto("http://localhost:3000/npm-module-nested");
await expect(page.locator("#server-fn-test")).toContainText(
'{"serverFnWithNpmModule":[2,4,6]}',
);
});
test("should have isServer true in the server function - toplevel", async ({ page }) => {
await page.goto("http://localhost:3000/is-server-toplevel");
await expect(page.locator("#server-fn-test")).toContainText('{"serverFnWithIsServer":true}');
});
test("should have an id of type string in the server function meta - toplevel", async ({
page,
}) => {
await page.goto("http://localhost:3000/server-function-meta");
await expect(page.locator("#server-fn-test")).toContainText('{"serverFnWithMeta":"string"}');
});
test("should externalize node builtin in server function - toplevel", async ({ page }) => {
await page.goto("http://localhost:3000/node-builtin-toplevel");
await expect(page.locator("#server-fn-test")).toContainText(
'{"serverFnWithNodeBuiltin":"can/externalize"}',
);
});
test("should externalize npm module in server function - toplevel", async ({ page }) => {
await page.goto("http://localhost:3000/npm-module-toplevel");
await expect(page.locator("#server-fn-test")).toContainText(
'{"serverFnWithNpmModule":[2,4,6]}',
);
});
test("should build when anon default export and server functions", async ({ page }) => {
await page.goto("http://localhost:3000/is-server-with-anon-default-export");
await expect(page.locator("#server-fn-test")).toContainText('{"serverFnWithIsServer":true}');
});
test("should build with generator as server function", async ({ page }) => {
await page.goto("http://localhost:3000/generator-server-function");
await expect(page.locator("#server-fn-test")).toContainText("¡Hola, Mundo!");
});
test("should build with a server function ping", async ({ page }) => {
await page.goto("http://localhost:3000/server-function-ping");
await expect(page.locator("#server-fn-test")).toContainText('{"result":true}');
});
test("should build with a server function w/ form data", async ({ page }) => {
await page.goto("http://localhost:3000/server-function-form-data");
await expect(page.locator("#server-fn-test")).toContainText('{"result":true}');
});
test("should build with a server function w/ blob data", async ({ page }) => {
await page.goto("http://localhost:3000/server-function-blob");
await expect(page.locator("#server-fn-test")).toContainText('{"result":true}');
});
});