Change:
<!-- Do Not Delete This! featurerequesttemplate --<!-- Please read our Rules of Conduct: --<!-- Please search existing issues to avoid creating duplicates. --- [x] Adopt a multi-stage pipeline for better visibility into dependencies [x] Review all test suites and ensure that they emit XML test results [x] Add pipeline task to publish the test results

Discussion:
const fs = require('fs'); const events = require('events'); const mocha = require('mocha'); <ins> const MochaJUnitReporter = require('mocha-junit-reporter'); </ins> const url = require('url'); const minimatch = require('minimatch'); const playwright = require('playwright');

} const withReporter = (function () { <del> const reporterPath = path.join(path.dirname(require.resolve('mocha')), 'lib', 'reporters', argv.reporter); let ctor; </del> <ins> if (argv.tfs) { { return (browserType, runner) => { new mocha.reporters.Spec(runner); new MochaJUnitReporter(runner, { reporterOptions: { testsuitesTitle: `${argv.tfs} ${process.platform}`, mochaFile: process.env.BUILD_ARTIFACTSTAGINGDIRECTORY ? path.join(process.env.BUILD_ARTIFACTSTAGINGDIRECTORY, `test-results/${process.platform}-${browserType}-${argv.tfs.toLowerCase().replace(/[^w]/g, '-')}-results.xml`) : undefined } }); } } } else { const reporterPath = path.join(path.dirname(require.resolve('mocha')), 'lib', 'reporters', argv.reporter); let ctor; </ins> <del> try { ctor = require(reporterPath); } catch (err) { </del> try { <del> ctor = require(argv.reporter); </del> <ins> ctor = require(reporterPath); </ins> } catch (err) { <del> ctor = process.platform === 'win32' ? mocha.reporters.List : mocha.reporters.Spec; console.warn(`could not load reporter: ${argv.reporter}, using ${ctor.name}`); </del> <ins> try { ctor = require(argv.reporter); } catch (err) { ctor = process.platform === 'win32' ? mocha.reporters.List : mocha.reporters.Spec; console.warn(`could not load reporter: ${argv.reporter}, using ${ctor.name}`); } </ins> } <del> } function parseReporterOption(value) { let r = /^([^=]+)=(.*)$/.exec(value); return r ? { [r[1]]: r[2] } : {}; } </del> <ins> function parseReporterOption(value) { let r = /^([^=]+)=(.*)$/.exec(value); return r ? { [r[1]]: r[2] } : {}; } </ins> <del> let reporterOptions = argv['reporter-options']; reporterOptions = typeof reporterOptions === 'string' ? [reporterOptions] : reporterOptions; reporterOptions = reporterOptions.reduce((r, o) => Object.assign(r, parseReporterOption(o)), {}); </del> <ins> let reporterOptions = argv['reporter-options']; reporterOptions = typeof reporterOptions === 'string' ? [reporterOptions] : reporterOptions; reporterOptions = reporterOptions.reduce((r, o) => Object.assign(r, parseReporterOption(o)), {}); </ins> <del> return (runner) => new ctor(runner, { reporterOptions }) </del> <ins> return (_, runner) => new ctor(runner, { reporterOptions }) } </ins> })() const outdir = argv.build ? 'out-build' : 'out';

console[msg.type()](msg.text(), await Promise.all(msg.args().map(async arg => await arg.jsonValue()))); }); <del> withReporter(new EchoRunner(emitter, browserType.toUpperCase())); </del> <ins> withReporter(browserType, new EchoRunner(emitter, browserType.toUpperCase())); </ins> // collection failures for console printing const fails = [];

const path = require('path'); const mocha = require('mocha'); const events = require('events'); <del> // const MochaJUnitReporter = require('mocha-junit-reporter'); </del> <ins> const MochaJUnitReporter = require('mocha-junit-reporter'); </ins> const url = require('url'); const defaultReporterName = process.platform === 'win32' ? 'list' : 'spec';

if (argv.tfs) { new mocha.reporters.Spec(runner); <del> // TODO@deepak the mocha Junit reporter seems to cause a hang when running with Electron 6 inside docker container // new MochaJUnitReporter(runner, { // 	reporterOptions: { // 		testsuitesTitle: `${argv.tfs} ${process.platform}`, // 		mochaFile: process.env.BUILD_ARTIFACTSTAGINGDIRECTORY ? path.join(process.env.BUILD_ARTIFACTSTAGINGDIRECTORY, `test-results/${process.platform}-${argv.tfs.toLowerCase().replace(/[^w]/g, '-')}-results.xml`) : undefined // 	} // }); </del> <ins> new MochaJUnitReporter(runner, { reporterOptions: { testsuitesTitle: `${argv.tfs} ${process.platform}`, mochaFile: process.env.BUILD_ARTIFACTSTAGINGDIRECTORY ? path.join(process.env.BUILD_ARTIFACTSTAGINGDIRECTORY, `test-results/${process.platform}-${argv.tfs.toLowerCase().replace(/[^w]/g, '-')}-results.xml`) : undefined } }); </ins> } else { const reporterPath = path.join(path.dirname(require.resolve('mocha')), 'lib', 'reporters', argv.reporter); let Reporter;