Files
studio-desktop/playwright.setup.ts
filteredandGitHub 725be94c01 [Dev] Finalise developer exp. improvements for e2e testing (#909)
* Add cursor rules for e2e testing

* [DevExp] Disable local volatile testing by default

* [Debug] Add Playwright reporters

* [Debug] Record all traces

* Revert "[Debug] Record all traces"

This reverts commit 46b5c44aa3d74e4dae262a5999edd3a4e5e40deb.

* Fix Playwright setup project hoisting

- Works around CI ordering issue
- Creates frustrating UX when running individual tests
- Projects can be disabled when iterating locally, in order to reduce the impact of chaining
2025-02-16 04:44:40 +11:00

28 lines
1.0 KiB
TypeScript

import { rename } from 'node:fs/promises';
import { assertPlaywrightEnabled } from './tests/integration/testExtensions';
import { FilePermission, addRandomSuffix, getComfyUIAppDataPath, pathExists } from './tests/shared/utils';
/** Backs up app data - in case this was run on a non-ephemeral machine. Does nothing in CI. */
async function globalSetup() {
console.log('+ Playwright globalSetup called');
assertPlaywrightEnabled();
if (process.env.COMFYUI_E2E_INDIVIDUAL_TEST_MODE === '1') return;
const appDataPath = getComfyUIAppDataPath();
await backupByRenaming(appDataPath);
}
/** Backs up a the provided app data path by appending a random suffix. */
async function backupByRenaming(appDataPath: string) {
if (!(await pathExists(appDataPath, FilePermission.Writable))) return;
const newPath = addRandomSuffix(appDataPath);
console.warn(`AppData exists! Moving ${appDataPath} to ${newPath}. Remove manually if you do not require it.`);
await rename(appDataPath, newPath);
return newPath;
}
export default globalSetup;