forked from clerk/javascript
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglobal.teardown.ts
27 lines (23 loc) · 976 Bytes
/
global.teardown.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
import { test as setup } from '@playwright/test';
import { constants } from '../constants';
import { stateFile } from '../models/stateFile';
import { appConfigs } from '../presets';
import { killClerkJsHttpServer, parseEnvOptions } from '../scripts';
setup('teardown long running apps', async () => {
const { appUrl } = parseEnvOptions();
await killClerkJsHttpServer();
if (appUrl || !constants.CLEANUP) {
// if appUrl is provided, it means that the user is running an app manually
console.log('Skipping cleanup');
return;
}
const runningAppsFoundInStateFile = Object.values(stateFile.getLongRunningApps() ?? {});
if (runningAppsFoundInStateFile.length > 0) {
const matchingLongRunningApps = appConfigs.longRunningApps.getByPattern(
runningAppsFoundInStateFile.map(app => app.id),
);
await Promise.all(matchingLongRunningApps.map(app => app.destroy()));
}
stateFile.remove();
console.log('Long running apps destroyed');
});