const { spawn } = require('child_process'); const path = require('path'); const PLAYWRIGHT_CONFIG = path.join(__dirname, '../../playwright.miniprogram.config.ts'); function runTests() { console.log('Starting mini program tests...'); console.log(`Using Playwright config: ${PLAYWRIGHT_CONFIG}`); const playwright = spawn('npx', ['playwright', 'test', '--config', PLAYWRIGHT_CONFIG], { stdio: 'inherit', shell: true, }); playwright.on('close', (code) => { if (code === 0) { console.log('Mini program tests passed!'); process.exit(0); } else { console.error(`Mini program tests failed with code ${code}`); process.exit(code); } }); playwright.on('error', (error) => { console.error('Failed to start Playwright:', error); process.exit(1); }); } if (require.main === module) { runTests(); } module.exports = { runTests };