do not remove config on local e2e run
This commit is contained in:
5
client/playwright.config.ts
vendored
5
client/playwright.config.ts
vendored
@@ -8,6 +8,7 @@ import path from 'path';
|
||||
export default defineConfig({
|
||||
testDir: './tests/e2e',
|
||||
globalSetup: path.resolve('./tests/e2e/globalSetup.ts'),
|
||||
globalTeardown: path.resolve('./tests/e2e/globalTeardown.ts'),
|
||||
timeout: 5000,
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
@@ -41,9 +42,7 @@ export default defineConfig({
|
||||
|
||||
webServer: {
|
||||
stdout: process.env.CI ? 'pipe' : 'ignore',
|
||||
command: process.env.CI
|
||||
? './AdGuardHome --local-frontend -v'
|
||||
: 'rm -f AdGuardHome.yaml && sudo ./AdGuardHome --local-frontend -v',
|
||||
command: process.env.CI ? './AdGuardHome --local-frontend -v' : 'sudo ./AdGuardHome --local-frontend -v',
|
||||
url: 'http://127.0.0.1:3000',
|
||||
cwd: '..',
|
||||
reuseExistingServer: !process.env.CI,
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
import { chromium, FullConfig } from '@playwright/test';
|
||||
import { existsSync, renameSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
|
||||
import { ADMIN_USERNAME, ADMIN_PASSWORD, PORT } from '../constants';
|
||||
|
||||
export const CONFIG_FILE = 'AdGuardHome.yaml';
|
||||
export const TEMP_CONFIG_FILE = 'AdGuardHome.yaml.temp';
|
||||
|
||||
async function globalSetup(config: FullConfig) {
|
||||
// Backup existing config file if it exists
|
||||
if (existsSync(CONFIG_FILE)) {
|
||||
renameSync(CONFIG_FILE, TEMP_CONFIG_FILE);
|
||||
}
|
||||
|
||||
const browser = await chromium.launch({
|
||||
slowMo: 100,
|
||||
});
|
||||
|
||||
20
client/tests/e2e/globalTeardown.ts
Normal file
20
client/tests/e2e/globalTeardown.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { chromium, FullConfig } from '@playwright/test';
|
||||
|
||||
import { ADMIN_USERNAME, ADMIN_PASSWORD, PORT } from '../constants';
|
||||
|
||||
import { existsSync, renameSync, unlinkSync } from 'fs';
|
||||
import { CONFIG_FILE, TEMP_CONFIG_FILE } from './globalSetup';
|
||||
|
||||
async function globalTeardown() {
|
||||
// Remove the test config file
|
||||
if (existsSync(CONFIG_FILE)) {
|
||||
unlinkSync(CONFIG_FILE);
|
||||
}
|
||||
|
||||
// Restore the original config file if it exists
|
||||
if (existsSync(TEMP_CONFIG_FILE)) {
|
||||
renameSync(TEMP_CONFIG_FILE, CONFIG_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
export default globalTeardown;
|
||||
Reference in New Issue
Block a user