chore(tooling): 对齐协作规范与 Playwright 运行配置
统一设备配置和浏览器启动入口,加入窗口焦点守卫,并按运行隔离报告和追踪文件。
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright (C) 2025 QuantumNous
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation, either version 3 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import { mkdtemp, rm } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import path from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { spawn } from 'node:child_process';
|
||||
import { verifyBuild } from './verify-build.mjs';
|
||||
|
||||
const root = fileURLToPath(new URL('../', import.meta.url));
|
||||
const directory = await mkdtemp(path.join(tmpdir(), 'monkey-pw-build-'));
|
||||
const env = {
|
||||
...process.env,
|
||||
PW_TARGET: 'local-dist',
|
||||
PW_BASE_URL: 'http://127.0.0.1:4176/',
|
||||
PW_REQUIRE_ALL: '1',
|
||||
PW_DIST_DIR: directory,
|
||||
};
|
||||
function run(script, args) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const child = spawn(process.execPath, [script, ...args], {
|
||||
cwd: root,
|
||||
stdio: 'inherit',
|
||||
env,
|
||||
});
|
||||
child.on('error', reject);
|
||||
child.on('exit', (code) =>
|
||||
code === 0
|
||||
? resolve()
|
||||
: reject(new Error(`${path.basename(script)} failed (${code})`)),
|
||||
);
|
||||
});
|
||||
}
|
||||
try {
|
||||
await run(path.join(root, 'node_modules/vite/bin/vite.js'), [
|
||||
'build',
|
||||
'--outDir',
|
||||
directory,
|
||||
'--emptyOutDir',
|
||||
]);
|
||||
await verifyBuild(directory);
|
||||
await run(path.join(root, 'node_modules/@playwright/test/cli.js'), [
|
||||
'test',
|
||||
...process.argv.slice(2),
|
||||
]);
|
||||
} finally {
|
||||
await rm(directory, { recursive: true, force: true });
|
||||
}
|
||||
Reference in New Issue
Block a user