91 lines
2.5 KiB
JavaScript
91 lines
2.5 KiB
JavaScript
// #!/usr/bin/env node
|
|
//
|
|
// /**
|
|
// * 测试运行脚本
|
|
// * 提供命令行界面来运行测试
|
|
// */
|
|
// const {program} = require('commander');
|
|
// const {execSync} = require('child_process');
|
|
// const chalk = require('chalk');
|
|
// const path = require('path');
|
|
// const fs = require('fs');
|
|
//
|
|
// // 设置命令行选项
|
|
// program
|
|
// .version('1.0.0')
|
|
// .description('Playwright 自动化测试运行工具')
|
|
// .option('-b, --browser <browser>', '指定浏览器 (chromium, firefox, webkit)', 'chromium')
|
|
// .option('-t, --test <pattern>', '指定测试文件或目录')
|
|
// .option('-h, --headless', '无头模式运行', false)
|
|
// .option('-r, --reporter <reporter>', '指定报告格式 (list, html, json)', 'list')
|
|
// .option('-p, --parallel <number>', '并行运行数量', '3')
|
|
// .option('-s, --screenshot', '失败时截图', false)
|
|
// .option('-v, --video', '录制视频', false)
|
|
// .option('-d, --debug', '调试模式', false)
|
|
// .option('-u, --ui', '使用UI模式', false)
|
|
// .option('-c, --config <path>', '指定配置文件路径')
|
|
// .parse(process.argv);
|
|
//
|
|
// const options = program.opts();
|
|
//
|
|
// // 构建命令
|
|
// let command = 'npx playwright test';
|
|
//
|
|
// // 添加测试文件或目录
|
|
// if (options.test) {
|
|
// command += ` "${options.test}"`;
|
|
// }
|
|
//
|
|
// // 添加浏览器
|
|
// command += ` --project=${options.browser}`;
|
|
//
|
|
// // 添加报告格式
|
|
// if (options.reporter) {
|
|
// command += ` --reporter=${options.reporter}`;
|
|
// }
|
|
//
|
|
// // 添加并行数量
|
|
// if (options.parallel) {
|
|
// command += ` --workers=${options.parallel}`;
|
|
// }
|
|
//
|
|
// // 添加截图选项
|
|
// if (options.screenshot) {
|
|
// command += ' --screenshot=on';
|
|
// }
|
|
//
|
|
// // 添加视频选项
|
|
// if (options.video) {
|
|
// command += ' --video=on';
|
|
// }
|
|
//
|
|
// // 添加无头模式选项
|
|
// if (!options.headless) {
|
|
// command += ' --headed';
|
|
// }
|
|
//
|
|
// // 添加调试模式
|
|
// if (options.debug) {
|
|
// command += ' --debug';
|
|
// }
|
|
//
|
|
// // 添加UI模式
|
|
// if (options.ui) {
|
|
// command = 'npx playwright test --ui';
|
|
// }
|
|
//
|
|
// // 添加配置文件
|
|
// if (options.config) {
|
|
// command += ` --config="${options.config}"`;
|
|
// }
|
|
//
|
|
// console.log(chalk.blue('运行命令:'), chalk.yellow(command));
|
|
//
|
|
// try {
|
|
// // 执行命令
|
|
// execSync(command, {stdio: 'inherit'});
|
|
// console.log(chalk.green('测试完成!'));
|
|
// } catch (error) {
|
|
// console.error(chalk.red('测试执行失败:'), error.message);
|
|
// process.exit(1);
|
|
// }
|