Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: list reporter using last result prefix icon when in pending state #9

Merged
merged 1 commit into from
Mar 1, 2024
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: 2 additions & 0 deletions src/reporter/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ export class BaseReporter {
return chalk.yellow;
case "skipped":
return chalk.cyan;
case "pending":
return chalk.dim;
default:
return (str: string) => str;
}
Expand Down
18 changes: 11 additions & 7 deletions src/reporter/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class ListReporter extends BaseReporter {
this._testRows[test.id] = this.currentTest;
const fullName = test.titlePath();

const prefix = this._linePrefix(test);
const prefix = this._linePrefix(test, "start");
const line =
chalk.dim(fullName.join(" › ")) + this._lineSuffix(test, result);
this._appendLine(line, prefix);
Expand All @@ -39,7 +39,7 @@ export class ListReporter extends BaseReporter {
override endTest(test: TestCase, result: TestResult): void {
super.endTest(test, result);
const fullName = test.titlePath();
const prefix = this._linePrefix(test);
const prefix = this._linePrefix(test, "end");
const line =
this._resultColor(test.outcome())(fullName.join(" › ")) +
this._lineSuffix(test, result);
Expand All @@ -53,21 +53,25 @@ export class ListReporter extends BaseReporter {
}

private _resultIcon(status: TestStatus): string {
const color = this._resultColor(status);
switch (status) {
case "expected":
return chalk.green("✔");
return color("✔");
case "unexpected":
return chalk.red("✘");
return color("✘");
case "skipped":
return chalk.green("-");
case "pending":
return color("-");
default:
return " ";
}
}

private _linePrefix(test: TestCase): string {
private _linePrefix(test: TestCase, testPoint: "start" | "end"): string {
const row = this._testRows[test.id] ?? this.currentTest;
return ` ${this._resultIcon(test.outcome())} ${chalk.dim(row)} `;
return testPoint === "end"
? ` ${this._resultIcon(test.outcome())} ${chalk.dim(row)} `
: ` ${this._resultIcon("pending")} ${chalk.dim(row)} `;
}

private _lineSuffix(test: TestCase, result: TestResult): string {
Expand Down
Loading