08ea5fbe98
添加用户管理视图、API和状态管理文件
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
/**
|
|
* 全局测试设置
|
|
* 在所有测试开始前执行
|
|
*/
|
|
|
|
import { FullConfig } from '@playwright/test';
|
|
import { testConfig } from './test-config';
|
|
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
|
|
async function globalSetup(config: FullConfig) {
|
|
console.log('\n========== E2E测试开始 ==========');
|
|
console.log(`环境: ${testConfig.getEnvironmentName()}`);
|
|
console.log(`Admin URL: ${testConfig.getConfig().baseURL}`);
|
|
console.log(`Uniapp URL: ${testConfig.getConfig().uniappBaseURL}`);
|
|
console.log(`Mock模式: ${testConfig.isMockEnabled() ? '开启' : '关闭'}`);
|
|
console.log('================================\n');
|
|
|
|
// 创建测试目录
|
|
const dirs = [
|
|
'test-results',
|
|
'test-results/screenshots',
|
|
'test-results/videos',
|
|
'test-results/traces',
|
|
'test-results/integration',
|
|
];
|
|
|
|
dirs.forEach(dir => {
|
|
if (!fs.existsSync(dir)) {
|
|
fs.mkdirSync(dir, { recursive: true });
|
|
}
|
|
});
|
|
|
|
// 清理旧的测试结果
|
|
try {
|
|
const files = fs.readdirSync('test-results/artifacts');
|
|
files.forEach(file => {
|
|
fs.unlinkSync(path.join('test-results/artifacts', file));
|
|
});
|
|
} catch (e) {
|
|
// 忽略清理错误
|
|
}
|
|
}
|
|
|
|
export default globalSetup;
|