From 417b5d70aeb2386eb03a9c19e07b2cc1cc60be0b Mon Sep 17 00:00:00 2001 From: DudaGod Date: Mon, 22 Jul 2024 13:34:50 +0300 Subject: [PATCH] feat: add "pid" to log info with test result --- src/reporters/utils/helpers.js | 3 ++- test/src/reporters/flat.js | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/reporters/utils/helpers.js b/src/reporters/utils/helpers.js index 45b595a6b..8496997d1 100644 --- a/src/reporters/utils/helpers.js +++ b/src/reporters/utils/helpers.js @@ -23,10 +23,11 @@ exports.formatTestInfo = test => { const suiteName = test.fullTitle().replace(test.title, ""); const sessionId = test.sessionId ? `:${test.sessionId}` : ""; const reason = test.pending && ` reason: ${chalk.red(getSkipReason(test) || "no comment")}`; + const pid = test.meta?.pid ? `, pid:${test.meta.pid}` : ""; return ( ` ${suiteName}${chalk.underline(test.title)} [${chalk.yellow(test.browserId)}` + - `${sessionId}] - ${chalk.cyan(test.duration || 0)}ms${reason || ""}` + `${sessionId}${pid}] - ${chalk.cyan(test.duration || 0)}ms${reason || ""}` ); }; diff --git a/test/src/reporters/flat.js b/test/src/reporters/flat.js index aeb6e9c07..946eec32f 100644 --- a/test/src/reporters/flat.js +++ b/test/src/reporters/flat.js @@ -102,15 +102,26 @@ describe("Flat reporter", () => { TEST_FAIL: "failed", }; - it("should correctly do the rendering", async () => { - test = mkTestStub_({ sessionId: "test_session" }); + it("should render session id", async () => { + test = mkTestStub_({ sessionId: "500100" }); await createFlatReporter(); emit(RunnerEvents.TEST_PASS, test); const result = getDeserializedResult(informer.log.firstCall.args[0]); - assert.equal(result, "suite test [chrome:test_session] - 100500ms"); + assert.equal(result, "suite test [chrome:500100] - 100500ms"); + }); + + it("should render pid", async () => { + test = mkTestStub_({ meta: { pid: "12345" } }); + + await createFlatReporter(); + emit(RunnerEvents.TEST_PASS, test); + + const result = getDeserializedResult(informer.log.firstCall.args[0]); + + assert.equal(result, "suite test [chrome, pid:12345] - 100500ms"); }); describe("skipped tests report", () => {