(scenario)
| 77 | } |
| 78 | |
| 79 | function runScenario(scenario) { |
| 80 | return new Promise((resolve) => { |
| 81 | const env = { |
| 82 | ...process.env, |
| 83 | REPORT_NAME: reportName, |
| 84 | GROUP_NAME: groupName, |
| 85 | ARTIFACT_DIR: artifactRoot, |
| 86 | ARTIFACT_FLAT: '1', |
| 87 | ARTIFACT_PREFIX: `${scenario.id}_${scenario.title}`, |
| 88 | }; |
| 89 | |
| 90 | const child = spawn(process.execPath, [path.join(process.cwd(), scenario.script)], { |
| 91 | cwd: process.cwd(), |
| 92 | env, |
| 93 | stdio: ['ignore', 'pipe', 'pipe'], |
| 94 | }); |
| 95 | |
| 96 | let stdout = ''; |
| 97 | let stderr = ''; |
| 98 | child.stdout.on('data', (chunk) => { |
| 99 | stdout += chunk.toString(); |
| 100 | }); |
| 101 | child.stderr.on('data', (chunk) => { |
| 102 | stderr += chunk.toString(); |
| 103 | }); |
| 104 | child.on('close', (code) => { |
| 105 | const json = parseScenarioOutput(stdout, scenario); |
| 106 | resolve({ |
| 107 | code, |
| 108 | stdout, |
| 109 | stderr, |
| 110 | json, |
| 111 | scenario, |
| 112 | }); |
| 113 | }); |
| 114 | }); |
| 115 | } |
| 116 | |
| 117 | (async () => { |
| 118 | await fs.mkdir(artifactRoot, { recursive: true }); |
no test coverage detected