Skip to content

Commit

Permalink
push failed to the end
Browse files Browse the repository at this point in the history
  • Loading branch information
JairusSW committed Jul 16, 2024
1 parent 9b59270 commit 3a38426
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion assembly/__tests__/sleep.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe("Should sleep", () => {
test("100ms", () => {
const start = Date.now();
sleep(100);
expect(Date.now() - start).toBeGreaterOrEqualTo(100);
expect(Date.now() - start).toBeGreaterOrEqualTo(1010);
});
test("1s", () => {
const start = Date.now();
Expand Down
24 changes: 21 additions & 3 deletions reporters/log/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class LogReporter {
private passedTests: i32 = 0;
private failedTests: i32 = 0;

private passedMatches: i32 = 0;
private failedMatches: i32 = 0;
private failed: SuiteReport[] = [];


private initialized: boolean = false;
constructor(logs: Report[]) {
Expand Down Expand Up @@ -71,7 +71,7 @@ class LogReporter {
reportLog(log: Report): string {
// @ts-ignore
let out: string = "";

out += `${rainbow.bgCyanBright(" FILE ")} ${rainbow.dimMk(log.file)} ${rainbow.italicMk(log.time.format())}\n\n`;

for (let i = 0; i < log.groups.length; i++) {
Expand Down Expand Up @@ -102,6 +102,7 @@ class LogReporter {
for (let i = 0; i < suite.tests.length; i++) {
const _test = unchecked(suite.tests[i]);
if (_test.verdict != Verdict.Ok) {
if (!this.failed.includes(suite)) this.failed.push(suite);
out += this.reportTest(_test);
}
}
Expand Down Expand Up @@ -132,8 +133,25 @@ class LogReporter {
this.depthDec();
return out;
}
errors(): string {
let out: string = "";
if (!this.failed.length) return "";
out += rainbow.dimMk("----------------- [FAILED] -------------------\n\n");
for (let i = 0; i < this.failed.length; i++) {
const suite = unchecked(this.failed[i]);
out += `${rainbow.bgRed(" FAIL ")} ${rainbow.dimMk(suite.description)} ${rainbow.italicMk(suite.time.format())}\n\n`;
for (let i = 0; i < suite.tests.length; i++) {
const _test = unchecked(suite.tests[i]);
if (_test.verdict != Verdict.Ok) {
out += this.reportTest(_test);
}
}
}
return out;
}
summarize(): string {
let out: string = "";
out += this.errors();
out += rainbow.dimMk("----------------- [RESULTS] ------------------\n\n");

const filesResult = new Result("Files: ", this.failedFiles, this.passedFiles);
Expand Down

0 comments on commit 3a38426

Please sign in to comment.