Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"dev:be": "turbo run dev --parallel --env-mode=loose --filter=!@n8n/design-system --filter=!@n8n/chat --filter=!@n8n/task-runner --filter=!n8n-editor-ui",
"dev:ai": "turbo run dev --parallel --env-mode=loose --filter=@n8n/nodes-langchain --filter=n8n --filter=n8n-core",
"dev:fe": "run-p start \"dev:fe:editor --filter=@n8n/design-system\"",
"dev:fe:e2e": "run-p start dev:fe:editor",
"dev:fe:editor": "turbo run dev --parallel --env-mode=loose --filter=n8n-editor-ui",
"dev:e2e": "pnpm --filter=n8n-playwright dev --ui",
"clean": "turbo run clean",
Expand Down
27 changes: 27 additions & 0 deletions packages/testing/playwright/global-teardown.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { execSync } from 'child_process';

function globalTeardown() {
console.log('🧹 Starting global teardown...');

const ports = [5678, 8080];

for (const port of ports) {
try {
// Find process ID using the port
const pid = execSync(`lsof -ti :${port}`, { encoding: 'utf-8' }).trim();

if (pid) {
console.log(`- Killing process ${pid} on port ${port}`);
execSync(`kill -9 ${pid}`);
}
} catch (error) {
// lsof returns non-zero exit code if no process is found
console.log(`- No process found on port ${port}`);
}
}

console.log('🏁 Global teardown completed');
}

// eslint-disable-next-line import-x/no-default-export
export default globalTeardown;
60 changes: 40 additions & 20 deletions packages/testing/playwright/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import type { CurrentsFixtures, CurrentsWorkerFixtures } from '@currents/playwright';
import { currentsReporter } from '@currents/playwright';
import { defineConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
import os from 'os';
import path from 'path';

Expand Down Expand Up @@ -39,13 +40,49 @@ const WORKERS = IS_DEV ? 1 : IS_CI ? CI_WORKERS : LOCAL_WORKERS;

const BACKEND_URL = getBackendUrl();
const FRONTEND_URL = getFrontendUrl();
const START_COMMAND = IS_DEV ? 'pnpm dev:fe:e2e' : 'pnpm start';
const WEB_SERVER_URL = FRONTEND_URL ?? BACKEND_URL;

const EXPECT_TIMEOUT = IS_DEV ? 20000 : 10000;

const webServer: PlaywrightTestConfig['webServer'] = [];

if (BACKEND_URL) {
webServer.push({
command: 'cd .. && pnpm start',
url: `${BACKEND_URL}/favicon.ico`,
timeout: 30000,
reuseExistingServer: IS_DEV ? false : true,
env: {
DB_SQLITE_POOL_SIZE: '40',
E2E_TESTS: 'true',
N8N_PORT: getPortFromUrl(BACKEND_URL),
N8N_USER_FOLDER: USER_FOLDER,
N8N_LOG_LEVEL: 'debug',
N8N_METRICS: 'true',
N8N_RESTRICT_FILE_ACCESS_TO: '',
N8N_DYNAMIC_BANNERS_ENABLED: 'false',
...getTestEnv(),
},
});
}

if (FRONTEND_URL) {
webServer.push({
command: 'cd .. && pnpm dev:fe:editor',
url: `${FRONTEND_URL}/favicon.ico`,
timeout: 30000,
reuseExistingServer: IS_DEV ? false : true,
env: {
E2E_TESTS: 'true',
N8N_PORT: getPortFromUrl(FRONTEND_URL),
...getTestEnv(),
},
});
}

export default defineConfig<CurrentsFixtures, CurrentsWorkerFixtures>({
globalSetup: './global-setup.ts',
globalTeardown: IS_DEV ? './global-teardown.ts' : undefined,
forbidOnly: IS_CI,
retries: IS_CI ? 2 : 0,
workers: WORKERS,
Expand All @@ -56,27 +93,10 @@ export default defineConfig<CurrentsFixtures, CurrentsWorkerFixtures>({
projects: getProjects(),

// We use this if an n8n url is passed in. If the server is already running, we reuse it.
webServer: BACKEND_URL
? {
command: `cd .. && ${START_COMMAND}`,
url: `${WEB_SERVER_URL}/favicon.ico`,
timeout: 30000,
reuseExistingServer: true,
env: {
DB_SQLITE_POOL_SIZE: '40',
E2E_TESTS: 'true',
N8N_PORT: getPortFromUrl(BACKEND_URL),
N8N_USER_FOLDER: USER_FOLDER,
N8N_LOG_LEVEL: 'debug',
N8N_METRICS: 'true',
N8N_RESTRICT_FILE_ACCESS_TO: '',
N8N_DYNAMIC_BANNERS_ENABLED: 'false',
...getTestEnv(),
},
}
: undefined,
webServer,

use: {
baseURL: WEB_SERVER_URL,
trace: 'on',
video: 'on',
screenshot: 'on',
Expand Down