-
-
Notifications
You must be signed in to change notification settings - Fork 142
/
Copy pathmulti-platform.spec.ts
97 lines (90 loc) · 2.23 KB
/
multi-platform.spec.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { execSync } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { rm } from 'node:fs/promises';
import { expect } from '@playwright/test';
import { test } from './utils.js';
const dryRunList = [
// without entries.tsx
{
cwd: fileURLToPath(new URL('./fixtures/partial-build', import.meta.url)),
project: 'partial-build',
},
// with entries.tsx
{
cwd: fileURLToPath(new URL('./fixtures/ssr-basic', import.meta.url)),
project: 'ssr-basic',
},
];
const waku = fileURLToPath(
new URL('../packages/waku/dist/cli.js', import.meta.url),
);
const buildPlatformTarget = [
{
platform: '--with-vercel',
clearDirOrFile: ['dist', '.vercel'],
},
{
platform: '--with-vercel-static',
clearDirOrFile: ['dist'],
},
{
platform: '--with-netlify',
clearDirOrFile: ['dist', 'netlify', 'netlify.toml'],
},
{
platform: '--with-netlify-static',
clearDirOrFile: ['dist'],
},
{
platform: '--with-cloudflare',
clearDirOrFile: ['dist', 'wrangler.toml'],
},
{
platform: '--with-partykit',
clearDirOrFile: ['dist', 'partykit.json'],
},
{
platform: '--with-deno',
clearDirOrFile: ['dist'],
},
{
platform: '--with-aws-lambda',
clearDirOrFile: ['dist'],
},
];
const cleanListAfterBuild = new Set(
buildPlatformTarget.reduce(
(prev: string[], { clearDirOrFile }) => [...prev, ...clearDirOrFile],
[],
),
);
test.describe(`multi platform builds`, () => {
for (const { cwd, project } of dryRunList) {
for (const { platform, clearDirOrFile } of buildPlatformTarget) {
test(`build ${project} with ${platform} should not throw error`, async () => {
for (const name of clearDirOrFile) {
await rm(`${cwd}/${name}`, {
recursive: true,
force: true,
});
}
try {
execSync(`node ${waku} build ${platform}`, {
cwd,
env: process.env,
});
} catch (error) {
expect(error).toBeNull();
}
});
}
test.afterAll(async () => {
for (const name of cleanListAfterBuild) {
await rm(`${cwd}/${name}`, {
recursive: true,
force: true,
});
}
});
}
});