Skip to content

Commit

Permalink
feat: add "pid" to log info with test result
Browse files Browse the repository at this point in the history
  • Loading branch information
DudaGod committed Jul 22, 2024
1 parent 406a2d4 commit 417b5d7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/reporters/utils/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || ""}`
);
};

Expand Down
17 changes: 14 additions & 3 deletions test/src/reporters/flat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down

0 comments on commit 417b5d7

Please sign in to comment.