Skip to content

Commit 20947f7

Browse files
test(e2e): harden startup for federated-css-react-ssr, federated-css mono, vue2-in-vue3 (sequential start, HTTP waits, longer timeouts); switch some to dev servers; add wait-on
1 parent b5716c2 commit 20947f7

File tree

7 files changed

+385
-417
lines changed

7 files changed

+385
-417
lines changed

federated-css-react-ssr/playwright.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ export default defineConfig({
3535
cwd: __dirname,
3636
port: 3001,
3737
reuseExistingServer: reuseExisting,
38-
timeout: 300_000,
38+
timeout: 480_000,
3939
},
4040
{
4141
// Start all shells and wait until all ports 4000-4005 respond
4242
command: 'node scripts/start-shells.cjs',
4343
cwd: __dirname,
4444
port: 4005,
4545
reuseExistingServer: reuseExisting,
46-
timeout: 300_000,
46+
timeout: 480_000,
4747
},
4848
],
4949
});

federated-css-react-ssr/scripts/start-exposes.cjs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const { spawn } = require('node:child_process');
22
const path = require('node:path');
3+
const waitOn = require('wait-on');
34

45
const root = path.resolve(__dirname, '..');
56

@@ -9,11 +10,29 @@ function run(cmd, args, opts = {}) {
910

1011
async function main() {
1112
// build all exposes, then serve all
13+
console.log('[exposes] building all expose apps...');
1214
await new Promise((resolve, reject) => {
1315
const p = run('pnpm', ['--filter', '"federated-css-react-ssr_expose-*"', '-r', 'run', 'build']);
1416
p.on('exit', code => (code === 0 ? resolve() : reject(new Error('build exposes failed'))));
1517
});
18+
console.log('[exposes] starting static servers for exposes...');
1619
const pServe = run('pnpm', ['--filter', '"federated-css-react-ssr_expose-*"', '-r', 'run', 'serve']);
20+
21+
// Wait for all expose ports to be reachable before proceeding
22+
await waitOn({
23+
resources: [
24+
'http://localhost:3001',
25+
'http://localhost:3002',
26+
'http://localhost:3003',
27+
'http://localhost:3004',
28+
'http://localhost:3005',
29+
'http://localhost:3006',
30+
'http://localhost:3007',
31+
],
32+
timeout: 480000,
33+
validateStatus: s => s >= 200 && s < 500,
34+
});
35+
console.log('[exposes] all expose ports are up.');
1736
process.on('SIGINT', () => pServe.kill('SIGINT'));
1837
process.on('SIGTERM', () => pServe.kill('SIGTERM'));
1938
// keep process alive

federated-css-react-ssr/scripts/start-shells.cjs

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,46 @@ function run(cmd, args, opts = {}) {
88
return spawn(cmd, args, { stdio: 'inherit', cwd: root, shell: true, ...opts });
99
}
1010

11-
async function main() {
12-
// build all shells, then serve all, and wait for ports
13-
await new Promise((resolve, reject) => {
14-
const p = run('pnpm', ['--filter', '"federated-css-react-ssr_shell*"', '-r', 'run', 'build']);
15-
p.on('exit', code => (code === 0 ? resolve() : reject(new Error('build shells failed'))));
16-
});
17-
const pServe = run('pnpm', ['--filter', '"federated-css-react-ssr_shell*"', '-r', 'run', 'serve']);
18-
19-
await waitOn({
20-
resources: [
21-
'http://localhost:4000',
22-
'http://localhost:4001',
23-
'http://localhost:4002',
24-
'http://localhost:4003',
25-
'http://localhost:4004',
26-
'http://localhost:4005',
27-
],
28-
timeout: 300000,
29-
validateStatus: s => s >= 200 && s < 500,
11+
async function exec(cmd, args, opts = {}) {
12+
return new Promise((resolve, reject) => {
13+
const p = run(cmd, args, opts);
14+
p.on('exit', code => (code === 0 ? resolve() : reject(new Error(`${cmd} ${args.join(' ')} failed with code ${code}`))));
3015
});
16+
}
17+
18+
async function main() {
19+
// Build and start each shell sequentially to reduce CI CPU pressure.
20+
const shells = [
21+
{ dir: 'css-jss', port: 4000 },
22+
{ dir: 'css-scss', port: 4001 },
23+
{ dir: 'jss-styled-components', port: 4002 },
24+
{ dir: 'jss-styled-components-css-module', port: 4003 },
25+
{ dir: 'less-scss', port: 4004 },
26+
{ dir: 'scss-tailwind-css', port: 4005 },
27+
];
28+
29+
const procs = [];
30+
for (const { dir, port } of shells) {
31+
const cwd = path.join('shell-apps', dir);
32+
console.log(`[shells] building ${dir}...`);
33+
await exec('pnpm', ['-C', cwd, 'run', 'build']);
34+
35+
console.log(`[shells] starting ${dir} on port ${port}...`);
36+
const p = run('pnpm', ['-C', cwd, 'run', 'serve']);
37+
procs.push(p);
38+
39+
await waitOn({
40+
resources: [`http://localhost:${port}`],
41+
timeout: 480000,
42+
validateStatus: s => s >= 200 && s < 500,
43+
});
44+
console.log(`[shells] ${dir} is up on ${port}.`);
45+
}
46+
47+
const killAll = sig => procs.forEach(pr => pr.kill(sig));
48+
process.on('SIGINT', () => killAll('SIGINT'));
49+
process.on('SIGTERM', () => killAll('SIGTERM'));
3150

32-
process.on('SIGINT', () => pServe.kill('SIGINT'));
33-
process.on('SIGTERM', () => pServe.kill('SIGTERM'));
3451
// keep process alive
3552
await new Promise(() => {});
3653
}

federated-css/scripts/start-all.cjs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,19 @@ function run(cmd, args) {
99
}
1010

1111
async function main() {
12-
// Build consumers-react and exposes, then serve both groups; start Next consumers (dev)
13-
await new Promise((res, rej) => {
14-
const p = run('pnpm', ['--filter', '"@federated-css/*"', '-r', 'run', 'build']);
15-
p.on('exit', c => (c === 0 ? res() : rej(new Error('build consumers failed'))));
16-
});
12+
// Start consumers-react in dev (avoid heavy prod builds), build+serve exposes, and start Next dev servers
13+
console.log('[federated-css] starting consumers-react (dev servers)...');
14+
const pReact = run('pnpm', ['--filter', '"@federated-css/*"', '-r', 'run', 'start']);
15+
16+
console.log('[federated-css] building expose apps...');
1717
await new Promise((res, rej) => {
1818
const p = run('pnpm', ['--filter', '"federated-css-mono_expose-*"', '-r', 'run', 'build']);
1919
p.on('exit', c => (c === 0 ? res() : rej(new Error('build exposes failed'))));
2020
});
21-
22-
const pReact = run('pnpm', ['--filter', '"@federated-css/*"', '-r', 'run', 'serve']);
21+
console.log('[federated-css] serving expose apps...');
2322
const pExposes = run('pnpm', ['--filter', '"federated-css-mono_expose-*"', '-r', 'run', 'serve']);
23+
24+
console.log('[federated-css] starting Next consumers (dev servers)...');
2425
const pNext = run('pnpm', ['--filter', '"@federated-css/next-*"', '-r', 'run', 'start']);
2526

2627
await waitOn({
@@ -34,9 +35,10 @@ async function main() {
3435
// next consumers
3536
'http://localhost:8081', 'http://localhost:8082', 'http://localhost:8083', 'http://localhost:8084'
3637
],
37-
timeout: 300000,
38+
timeout: 480000,
3839
validateStatus: s => s >= 200 && s < 500,
3940
});
41+
console.log('[federated-css] all ports are up.');
4042

4143
const killAll = sig => { pReact.kill(sig); pExposes.kill(sig); pNext.kill(sig); };
4244
process.on('SIGINT', () => killAll('SIGINT'));
@@ -46,4 +48,3 @@ async function main() {
4648
}
4749

4850
main().catch(err => { console.error(err); process.exit(1); });
49-

0 commit comments

Comments
 (0)