-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathcypress.config.ts
More file actions
78 lines (63 loc) · 1.83 KB
/
cypress.config.ts
File metadata and controls
78 lines (63 loc) · 1.83 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
import { defineConfig } from 'cypress';
import cypressSplit from 'cypress-split';
import fkill from 'fkill';
import { runChainlit } from './cypress/support/run';
export const CHAINLIT_APP_PORT = 8000;
async function killChainlit() {
await fkill(`:${CHAINLIT_APP_PORT}`, {
force: true,
silent: true
});
}
['SIGTERM', 'SIGINT', 'SIGHUP', 'SIGBREAK'].forEach((signal) => {
process.on(signal, () => {
(async () => {
await killChainlit(); // Ensure Chainlit is killed on exit
const signalMap = { SIGTERM: 15, SIGINT: 2, SIGHUP: 1, SIGBREAK: 21 };
process.exit(128 + (signalMap[signal] || 0));
})();
});
});
export default defineConfig({
projectId: 'ij1tyk',
retries: 3,
viewportWidth: 1200,
e2e: {
defaultCommandTimeout: 30000,
baseUrl: `http://127.0.0.1:${CHAINLIT_APP_PORT}`,
experimentalInteractiveRunEvents: true,
async setupNodeEvents(on, config) {
cypressSplit(on, config);
await killChainlit(); // Fallback to ensure no previous instance is running
await runChainlit(); // Start Chainlit before running tests as Cypress require
on('before:spec', async (spec) => {
await killChainlit();
await runChainlit(spec);
});
on('after:spec', async () => {
await killChainlit();
});
on('after:run', async () => {
await killChainlit();
});
on('task', {
log(message) {
console.log(message);
return null;
},
restartChainlit(spec: Cypress.Spec) {
return new Promise((resolve) => {
killChainlit().then(() => {
runChainlit(spec).then(() => {
setTimeout(() => {
resolve(null);
}, 1000);
});
});
});
}
});
return config;
}
}
});