Skip to content

Commit

Permalink
Code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
sergii-nosachenko committed Jan 23, 2024
1 parent f628450 commit 45518a9
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 70 deletions.
8 changes: 4 additions & 4 deletions jest-mochawesome-reporter/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 7 additions & 66 deletions jest-mochawesome-reporter/src/jest-mochawesome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,72 +10,13 @@ import {
TestResult,
} from '@jest/reporters';
import { AssertionResult } from '@jest/test-result';

interface JestMochawesomeReporterOptions {
outputDir?: string;
outputName?: string;
createDirIfMissing?: boolean;
}

interface ErrorLog {
message: string;
estack: string;
}

interface Test {
title: string;
fullTitle: string;
timedOut: boolean;
duration: number;
pass: boolean;
fail: boolean;
pending: boolean;
code: string;
uuid: string;
parentUUID: string;
skipped: boolean;
isHook: boolean;
err: ErrorLog | Record<string, never>;
}

interface Suite {
title: string;
suites: Suite[];
tests: Test[];
pending: string[];
root: boolean;
uuid: string;
_timeout: number;
fullFile: string;
file: string;
beforeHooks: any[];
afterHooks: any[];
passes: string[];
failures: string[];
skipped: string[];
duration: number;
}

interface Report {
stats: {
suites: number;
tests: number;
testsRegistered: number;
passes: number;
pending: number;
failures: number;
start: Date;
end: Date;
duration: number;
passPercent: number;
pendingPercent: number;
other: number;
hasOther: boolean;
skipped: number;
hasSkipped: boolean;
};
results: Suite[];
}
import {
ErrorLog,
JestMochawesomeReporterOptions,
Suite,
Test,
Report,
} from './typedefs';

export default class JestMochawesomeReporter extends BaseReporter {
private readonly globalConfig: Config.GlobalConfig;
Expand Down
65 changes: 65 additions & 0 deletions jest-mochawesome-reporter/src/typedefs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
export interface JestMochawesomeReporterOptions {
outputDir?: string;
outputName?: string;
createDirIfMissing?: boolean;
}

export interface ErrorLog {
message: string;
estack: string;
}

export interface Test {
title: string;
fullTitle: string;
timedOut: boolean;
duration: number;
pass: boolean;
fail: boolean;
pending: boolean;
code: string;
uuid: string;
parentUUID: string;
skipped: boolean;
isHook: boolean;
err: ErrorLog | Record<string, never>;
}

export interface Suite {
title: string;
suites: Suite[];
tests: Test[];
pending: string[];
root: boolean;
uuid: string;
_timeout: number;
fullFile: string;
file: string;
beforeHooks: any[];
afterHooks: any[];
passes: string[];
failures: string[];
skipped: string[];
duration: number;
}

export interface Report {
stats: {
suites: number;
tests: number;
testsRegistered: number;
passes: number;
pending: number;
failures: number;
start: Date;
end: Date;
duration: number;
passPercent: number;
pendingPercent: number;
other: number;
hasOther: boolean;
skipped: number;
hasSkipped: boolean;
};
results: Suite[];
}

0 comments on commit 45518a9

Please sign in to comment.