(options, ...paths)
| 34 | const pauseOnFailure = args['--pause-on-failure'] |
| 35 | |
| 36 | const initPlaywright = (options, ...paths) => { |
| 37 | const argsToForward = args._ |
| 38 | const testArgs = ['test'] |
| 39 | const env = { ...process.env } |
| 40 | |
| 41 | if (testType) env.TEST_TYPE = testType |
| 42 | |
| 43 | if (!argsToForward.includes('--config')) { |
| 44 | testArgs.push('--config', 'playwright.config.ts') |
| 45 | } |
| 46 | |
| 47 | if (args['--chromium'] && !argsToForward.includes('--project=chromium')) { |
| 48 | testArgs.push('--project=chromium') |
| 49 | } |
| 50 | |
| 51 | if (pauseOnFailure) { |
| 52 | env.PAUSE_ON_FAILURE = true |
| 53 | |
| 54 | if (!argsToForward.includes('--headed')) { |
| 55 | testArgs.push('--headed') |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | let closed = false |
| 60 | |
| 61 | const instance = spawn( |
| 62 | 'playwright', |
| 63 | [...testArgs, ...argsToForward, ...paths], |
| 64 | { stdio: 'inherit', env } |
| 65 | ) |
| 66 | |
| 67 | if (options?.verbose !== false) { |
| 68 | console.log('>', instance.spawnargs.join(' ')) |
| 69 | if (testType || pauseOnFailure) { |
| 70 | console.log( |
| 71 | `> env: ${testType ? `TEST_TYPE=${testType}` : ''} ${ |
| 72 | pauseOnFailure ? 'PAUSE_ON_FAILURE=true' : '' |
| 73 | }` |
| 74 | ) |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | const events = new Promise((resolve, reject) => { |
| 79 | instance.on('close', (code, signal) => { |
| 80 | closed = true |
| 81 | if (code === 0) { |
| 82 | resolve() |
| 83 | } else { |
| 84 | reject(null) |
| 85 | } |
| 86 | }) |
| 87 | instance.on('error', (error) => { |
| 88 | reject(error) |
| 89 | }) |
| 90 | }) |
| 91 | |
| 92 | const kill = () => { |
| 93 | if (!closed && !instance.killed && instance.exitCode === null) { |
no outgoing calls
no test coverage detected