Skip to content

Commit 3efff0d

Browse files
committed
refactor(visual-regressions): use spawn to display report quit key
1 parent 7690a5d commit 3efff0d

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

core/scripts/testing/e2e-script.mjs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ import {
1414
text,
1515
log,
1616
} from '@clack/prompts';
17-
import { exec } from 'child_process';
17+
import { exec, spawn } from 'child_process';
1818
import fs from 'node:fs';
1919
import { setTimeout as sleep } from 'node:timers/promises';
2020
import util from 'node:util';
2121
import color from 'picocolors';
2222

2323
async function main() {
2424
const execAsync = util.promisify(exec);
25+
const spawnAsync = util.promisify(spawn);
2526
const cleanUpFiles = async () => {
2627
// Clean up the local ground truths.
2728
const cleanUp = spinner();
@@ -216,15 +217,21 @@ async function main() {
216217

217218
// User chose to open the Playwright report.
218219
if (shouldOpenReport) {
219-
await execAsync('npx playwright show-report').catch(() => {
220-
console.error('Error: Failed to open the Playwright report or user closed the report');
220+
// Use spawn to display the server information and the key to quit the server.
221+
spawn('npx', ['playwright', 'show-report'], {
222+
stdio: 'inherit',
221223
});
222224
} else {
223225
// Inform the user that the Playwright report can be opened by running the following command.
224-
log.info('You can open the Playwright report by running the following command: npx playwright show-report');
226+
log.info('If you change your mind, you can open the Playwright report by running the following command:');
227+
log.info(color.bold('npx playwright show-report'));
225228
}
226229

227-
outro("You're all set!");
230+
if (shouldOpenReport) {
231+
outro("You're all set! Don't forget to quit serving the Playwright report when you're done.");
232+
} else {
233+
outro("You're all set!");
234+
}
228235

229236
await sleep(1000);
230237
}

0 commit comments

Comments
 (0)