fix: e2e with build
This commit is contained in:
parent
3c87755e6c
commit
fd4809d8ad
@ -13,7 +13,7 @@ VERDACCIO_PORT=10104
|
|||||||
APP_ENV=development
|
APP_ENV=development
|
||||||
APP_PORT=20000
|
APP_PORT=20000
|
||||||
APP_KEY=test-key-e2e
|
APP_KEY=test-key-e2e
|
||||||
SOCKET_PATH=storage/gateway-e2e.sock
|
SOCKET_PATH=storage/e2e/gateway.sock
|
||||||
__E2E__=true
|
__E2E__=true
|
||||||
|
|
||||||
# 启用 mock-collections 插件
|
# 启用 mock-collections 插件
|
||||||
@ -26,18 +26,18 @@ PROXY_TARGET_URL=
|
|||||||
|
|
||||||
LOGGER_TRANSPORT=
|
LOGGER_TRANSPORT=
|
||||||
LOGGER_LEVEL=
|
LOGGER_LEVEL=
|
||||||
LOGGER_BASE_PATH=storage/logs-e2e
|
LOGGER_BASE_PATH=storage/e2e/logs
|
||||||
|
|
||||||
################# DATABASE #################
|
################# DATABASE #################
|
||||||
|
|
||||||
DB_DIALECT=sqlite
|
DB_DIALECT=postgres
|
||||||
DB_STORAGE=storage/db/nocobase-e2e.sqlite
|
DB_STORAGE=storage/e2e/db/nocobase.sqlite
|
||||||
DB_TABLE_PREFIX=
|
DB_TABLE_PREFIX=
|
||||||
# DB_HOST=localhost
|
DB_HOST=localhost
|
||||||
# DB_PORT=5432
|
DB_PORT=5432
|
||||||
# DB_DATABASE=nocobase-e2e
|
DB_DATABASE=nocobase-e2e
|
||||||
# DB_USER=nocobase
|
DB_USER=nocobase
|
||||||
# DB_PASSWORD=nocobase
|
DB_PASSWORD=nocobase
|
||||||
# DB_LOGGING=on
|
# DB_LOGGING=on
|
||||||
# DB_UNDERSCORED=false
|
# DB_UNDERSCORED=false
|
||||||
|
|
||||||
|
@ -149,7 +149,13 @@ module.exports = (cli) => {
|
|||||||
.allowUnknownOption()
|
.allowUnknownOption()
|
||||||
.option('--url [url]')
|
.option('--url [url]')
|
||||||
.option('--skip-reporter')
|
.option('--skip-reporter')
|
||||||
|
.option('--build')
|
||||||
.action(async (options) => {
|
.action(async (options) => {
|
||||||
|
process.env.__E2E__ = true;
|
||||||
|
if (options.build) {
|
||||||
|
process.env.APP_ENV = 'production';
|
||||||
|
await run('yarn', ['build']);
|
||||||
|
}
|
||||||
if (options.skipReporter) {
|
if (options.skipReporter) {
|
||||||
process.env.PLAYWRIGHT_SKIP_REPORTER = true;
|
process.env.PLAYWRIGHT_SKIP_REPORTER = true;
|
||||||
}
|
}
|
||||||
@ -184,8 +190,13 @@ module.exports = (cli) => {
|
|||||||
e2e
|
e2e
|
||||||
.command('start-app')
|
.command('start-app')
|
||||||
.option('--production')
|
.option('--production')
|
||||||
|
.option('--build')
|
||||||
.option('--port [port]')
|
.option('--port [port]')
|
||||||
.action(async (options) => {
|
.action(async (options) => {
|
||||||
|
process.env.__E2E__ = true;
|
||||||
|
if (options.build) {
|
||||||
|
await run('yarn', ['build']);
|
||||||
|
}
|
||||||
if (options.production) {
|
if (options.production) {
|
||||||
process.env.APP_ENV = 'production';
|
process.env.APP_ENV = 'production';
|
||||||
}
|
}
|
||||||
@ -206,8 +217,14 @@ module.exports = (cli) => {
|
|||||||
e2e
|
e2e
|
||||||
.command('p-test')
|
.command('p-test')
|
||||||
.option('--stop-on-error')
|
.option('--stop-on-error')
|
||||||
|
.option('--build')
|
||||||
.option('--concurrency [concurrency]', '', os.cpus().length)
|
.option('--concurrency [concurrency]', '', os.cpus().length)
|
||||||
.action(async (opts) => {
|
.action(async (options) => {
|
||||||
await pTest(opts);
|
process.env.__E2E__ = true;
|
||||||
|
if (options.build) {
|
||||||
|
process.env.APP_ENV = 'production';
|
||||||
|
await run('yarn', ['build']);
|
||||||
|
}
|
||||||
|
await pTest(options);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -47,14 +47,20 @@ async function runApp(dir, index = 0) {
|
|||||||
APP_ENV: 'production',
|
APP_ENV: 'production',
|
||||||
APP_PORT: 20000 + index,
|
APP_PORT: 20000 + index,
|
||||||
DB_DATABASE: `nocobase${index}`,
|
DB_DATABASE: `nocobase${index}`,
|
||||||
SOCKET_PATH: `storage/gateway-e2e-${index}.sock`,
|
SOCKET_PATH: `storage/e2e/gateway-e2e-${index}.sock`,
|
||||||
PM2_HOME: resolve(process.cwd(), `storage/.pm2-${index}`),
|
PM2_HOME: resolve(process.cwd(), `storage/e2e/.pm2-${index}`),
|
||||||
PLAYWRIGHT_AUTH_FILE: resolve(process.cwd(), `storage/playwright/.auth/admin-${index}.json`),
|
PLAYWRIGHT_AUTH_FILE: resolve(process.cwd(), `storage/playwright/.auth/admin-${index}.json`),
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.pTest = async (options) => {
|
exports.pTest = async (options) => {
|
||||||
|
const dir = resolve(process.cwd(), 'storage/e2e');
|
||||||
|
|
||||||
|
if (!fs.existsSync(dir)) {
|
||||||
|
fs.mkdirSync(dir, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
const files = glob.sync('packages/**/__e2e__/**/*.test.ts', {
|
const files = glob.sync('packages/**/__e2e__/**/*.test.ts', {
|
||||||
root: process.cwd(),
|
root: process.cwd(),
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import net from 'net';
|
import net from 'net';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
import path from 'path';
|
||||||
import { AppSupervisor } from '../app-supervisor';
|
import { AppSupervisor } from '../app-supervisor';
|
||||||
import { writeJSON } from './ipc-socket-client';
|
import { writeJSON } from './ipc-socket-client';
|
||||||
import { randomUUID } from 'crypto';
|
import { randomUUID } from 'crypto';
|
||||||
@ -17,6 +18,12 @@ export class IPCSocketServer {
|
|||||||
fs.unlinkSync(socketPath);
|
fs.unlinkSync(socketPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const dir = path.dirname(socketPath);
|
||||||
|
|
||||||
|
if (!fs.existsSync(dir)) {
|
||||||
|
fs.mkdirSync(dir, { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
const socketServer = net.createServer((c) => {
|
const socketServer = net.createServer((c) => {
|
||||||
console.log('client connected');
|
console.log('client connected');
|
||||||
|
|
||||||
|
3
storage/.gitignore
vendored
3
storage/.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
.pm2
|
.pm2
|
||||||
tmp
|
tmp
|
||||||
app.watch.ts
|
app.watch.ts
|
||||||
|
/e2e
|
Loading…
Reference in New Issue
Block a user