Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/profiler/output/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface ProfilerConsole {
}

const defaultConsole: ProfilerConsole = {
log: message => console.log(message),
log: message => console.error(message),
warn: message => console.warn(message),
};

Expand Down
15 changes: 15 additions & 0 deletions test/src/profiler/output/console.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import chalk from "chalk";
import sinon from "sinon";

import { printProfilerResult } from "src/profiler/output/console";
import type { Finding, ProcessRef, ProfilerConfidence, ProfilerResultV1, RetainedOperation } from "src/profiler/schema";

describe("profiler/output/console", () => {
const sandbox = sinon.createSandbox();
const ansiPattern = new RegExp(`${String.fromCharCode(27)}\\[[0-9;]*m`, "g");
const withoutColors = (value: string): string => value.replace(ansiPattern, "");

afterEach(() => sandbox.restore());

const finding = (
analyzerId: string,
confidence: ProfilerConfidence,
Expand Down Expand Up @@ -135,6 +139,17 @@ describe("profiler/output/console", () => {
}
};

it("should print the default report to stderr", () => {
const stdout = sandbox.stub(console, "log");
const stderr = sandbox.stub(console, "error");

printProfilerResult(makeResult());

assert.notCalled(stdout);
assert.calledOnce(stderr);
assert.match(stderr.firstCall.args[0], /^\[profiler] Test run profile/);
});

it("should print one aligned report with phase and slow-test tables", () => {
const durationMs = 246_000;
const session = finding("session-concurrency-v1", "high", 183_000, "chrome", 194);
Expand Down
Loading