feat(html): add --host and --port to the show-report command (#18517)

This enables serving HTML report from inside docker container.

Drive-by: restore default HTML serving port to 9323. This was
accidentally changed in 1.27 and mentioned in

https://github.com/microsoft/playwright/issues/16667#issuecomment-1269861623
This commit is contained in:
Andrey Lushnikov 2022-11-02 15:12:48 -07:00 committed by GitHub
parent 4d34a1a371
commit c3cff485d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 2 deletions

View File

@ -100,7 +100,9 @@ function addListFilesCommand(program: Command) {
function addShowReportCommand(program: Command) {
const command = program.command('show-report [report]');
command.description('show HTML report');
command.action(report => showHTMLReport(report));
command.action((report, options) => showHTMLReport(report, options.host, +options.port));
command.option('--host <host>', 'Host to serve report on', 'localhost');
command.option('--port <port>', 'Port to serve report on', '9323');
command.addHelpText('afterAll', `
Arguments [report]:
When specified, opens given report, otherwise opens last generated report.

View File

@ -159,7 +159,7 @@ export async function showHTMLReport(reportFolder: string | undefined, host: str
return;
}
const server = startHtmlReportServer(folder);
let url = await server.start({ port, host, preferredPort: port ? undefined : 9223 });
let url = await server.start({ port, host, preferredPort: port ? undefined : 9323 });
console.log('');
console.log(colors.cyan(` Serving HTML report at ${url}. Press Ctrl+C to quit.`));
if (testId)