Skip to content

Commit

Permalink
fix: resolve merge conflicts and update function calls
Browse files Browse the repository at this point in the history
  • Loading branch information
yharaskrik committed Jan 19, 2021
1 parent 53f9c68 commit e7070ac
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
9 changes: 3 additions & 6 deletions lib/CleanConsoleReporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,18 @@ export class CleanConsoleReporter extends DefaultReporter {
console: this.filterOutKnownMessages(result.console),
};

DefaultReporter.prototype.printTestFileHeader.call(this, testPath, config,
filteredResult);
super.printTestFileHeader(testPath, config, filteredResult);
}

filterOutKnownMessages(consoleBuffer: LogEntry[] = []) {
const rules = this.rules;
const retain: LogEntry[] = [];

for (const frame of consoleBuffer) {
const {type, message} = frame;

// Check if this a known type message
const [key, keep] = getLogGroupKey(rules, message, type);
const [key, keep] = getLogGroupKey(rules, frame);
if (key) {
this.groupMessageByKey(type, key);
this.groupMessageByKey(frame.type, key);
if (keep) {
retain.push(frame);
}
Expand Down
5 changes: 3 additions & 2 deletions lib/getLogGroupKey.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* global module */
import {Group, Matcher, Rule} from "./types";
import {LogType} from "@jest/console";
import {LogEntry} from "@jest/console/build/types";

export const matchWith = (matcher: Matcher, message: string, type: LogType, origin) => {
export const matchWith = (matcher: Matcher, message: string, type: LogType, origin: string) => {
if (matcher instanceof RegExp) {
return matcher.test(message);
}
Expand Down Expand Up @@ -40,7 +41,7 @@ const formatMessage = (formatter: Group, message: string, type: LogType, matcher
return message;
};

const getLogGroupKey = (rules: Rule[], { message, type, origin }) => {
export const getLogGroupKey = (rules: Rule[], { message, type, origin }: LogEntry): [string | null, boolean] | [] => {
for (let { match: matcher, group: formatter, keep = false } of rules) {
if (matchWith(matcher, message, type, origin)) {
return [formatMessage(formatter, message, type, matcher), keep];
Expand Down
2 changes: 1 addition & 1 deletion lib/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {LogType} from "@jest/console";

export type Matcher = RegExp | string | ((message: string, type: LogType) => boolean)
export type Matcher = RegExp | string | ((message: string, type: LogType, origin: string) => boolean)

export type Group = string | null | ((message: string, type: LogType, matcher: Matcher) => string | null)

Expand Down

0 comments on commit e7070ac

Please sign in to comment.