mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
ci(core): Extract local e2e run script (no-changelog) (#7551)
Github issue / Community forum post (link here to close automatically): --------- Signed-off-by: Oleg Ivaniv <me@olegivaniv.com> Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
parent
bfa28b9532
commit
3ab04e4f9e
|
@ -28,9 +28,9 @@
|
|||
"worker": "./packages/cli/bin/n8n worker",
|
||||
"cypress:install": "cypress install",
|
||||
"cypress:open": "CYPRESS_BASE_URL=http://localhost:8080 cypress open",
|
||||
"test:e2e:ui": "cross-env E2E_TESTS=true NODE_OPTIONS=--dns-result-order=ipv4first start-server-and-test start http://localhost:5678/favicon.ico 'cypress open'",
|
||||
"test:e2e:dev": "cross-env E2E_TESTS=true NODE_OPTIONS=--dns-result-order=ipv4first CYPRESS_BASE_URL=http://localhost:8080 start-server-and-test dev http://localhost:8080/favicon.ico 'cypress open'",
|
||||
"test:e2e:all": "cross-env E2E_TESTS=true NODE_OPTIONS=--dns-result-order=ipv4first start-server-and-test start http://localhost:5678/favicon.ico 'cypress run --headless'"
|
||||
"test:e2e:ui": "scripts/run-e2e.js ui",
|
||||
"test:e2e:dev": "scripts/run-e2e.js dev",
|
||||
"test:e2e:all": "scripts/run-e2e.js all"
|
||||
},
|
||||
"dependencies": {
|
||||
"n8n": "workspace:*"
|
||||
|
|
|
@ -1,19 +1,14 @@
|
|||
import convict from 'convict';
|
||||
import dotenv from 'dotenv';
|
||||
import { tmpdir } from 'os';
|
||||
import { mkdirSync, mkdtempSync, readFileSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { readFileSync } from 'fs';
|
||||
import { setGlobalState } from 'n8n-workflow';
|
||||
import { schema } from './schema';
|
||||
import { inTest, inE2ETests } from '@/constants';
|
||||
|
||||
if (inE2ETests) {
|
||||
const testsDir = join(tmpdir(), 'n8n-e2e/');
|
||||
mkdirSync(testsDir, { recursive: true });
|
||||
// Skip loading config from env variables in end-to-end tests
|
||||
process.env = {
|
||||
E2E_TESTS: 'true',
|
||||
N8N_USER_FOLDER: mkdtempSync(testsDir),
|
||||
EXECUTIONS_PROCESS: 'main',
|
||||
N8N_DIAGNOSTICS_ENABLED: 'false',
|
||||
N8N_PUBLIC_API_DISABLED: 'true',
|
||||
|
|
70
scripts/run-e2e.js
Executable file
70
scripts/run-e2e.js
Executable file
|
@ -0,0 +1,70 @@
|
|||
#!/usr/bin/env node
|
||||
const { spawn } = require('child_process');
|
||||
const { mkdirSync, mkdtempSync } = require('fs');
|
||||
const { tmpdir } = require('os');
|
||||
const { join } = require('path');
|
||||
|
||||
function runTests(options) {
|
||||
const testsDir = join(tmpdir(), 'n8n-e2e/');
|
||||
mkdirSync(testsDir, { recursive: true });
|
||||
|
||||
const userFolder = mkdtempSync(testsDir);
|
||||
|
||||
process.env.N8N_USER_FOLDER = userFolder;
|
||||
process.env.E2E_TESTS = 'true';
|
||||
process.env.NODE_OPTIONS = '--dns-result-order=ipv4first';
|
||||
|
||||
if (options.customEnv) {
|
||||
Object.keys(options.customEnv).forEach((key) => {
|
||||
process.env[key] = options.customEnv[key];
|
||||
});
|
||||
}
|
||||
|
||||
const cmd = `start-server-and-test ${options.startCommand} ${options.url} '${options.testCommand}'`;
|
||||
const testProcess = spawn(cmd, [], { stdio: 'inherit', shell: true });
|
||||
|
||||
// Listen for termination signals to properly kill the test process
|
||||
process.on('SIGINT', () => {
|
||||
testProcess.kill('SIGINT');
|
||||
});
|
||||
|
||||
process.on('SIGTERM', () => {
|
||||
testProcess.kill('SIGTERM');
|
||||
});
|
||||
|
||||
testProcess.on('exit', (code) => {
|
||||
process.exit(code);
|
||||
});
|
||||
}
|
||||
|
||||
const scenario = process.argv[2];
|
||||
|
||||
switch (scenario) {
|
||||
case 'ui':
|
||||
runTests({
|
||||
startCommand: 'start',
|
||||
url: 'http://localhost:5678/favicon.ico',
|
||||
testCommand: 'cypress open',
|
||||
});
|
||||
break;
|
||||
case 'dev':
|
||||
runTests({
|
||||
startCommand: 'dev',
|
||||
url: 'http://localhost:8080/favicon.ico',
|
||||
testCommand: 'cypress open',
|
||||
customEnv: {
|
||||
CYPRESS_BASE_URL: 'http://localhost:8080',
|
||||
},
|
||||
});
|
||||
break;
|
||||
case 'all':
|
||||
runTests({
|
||||
startCommand: 'start',
|
||||
url: 'http://localhost:5678/favicon.ico',
|
||||
testCommand: 'cypress run --headless',
|
||||
});
|
||||
break;
|
||||
default:
|
||||
console.error('Unknown scenario');
|
||||
process.exit(1);
|
||||
}
|
Loading…
Reference in a new issue