generated from ubiquity/ts-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: couple test, remove postComment refs
- Loading branch information
Showing
12 changed files
with
91 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const ansiEscapeCodes = /\x1b\[\d+m|\s/g; | ||
|
||
function cleanLogs( | ||
spy: jest.SpiedFunction<{ | ||
(...data: string[]): void; | ||
(message?: string, ...optionalParams: string[]): void; | ||
}> | ||
) { | ||
const strs = spy.mock.calls.map((call) => call.map((str) => str?.toString()).join(" ")); | ||
return strs.flat().map((str) => cleanLogString(str)); | ||
} | ||
|
||
export function cleanLogString(logString: string) { | ||
return logString.replaceAll(ansiEscapeCodes, "").replaceAll(/\n/g, "").replaceAll(/\r/g, "").replaceAll(/\t/g, "").trim(); | ||
} | ||
|
||
export function cleanSpyLogs( | ||
spy: jest.SpiedFunction<{ | ||
(...data: string[]): void; | ||
(message?: string, ...optionalParams: string[]): void; | ||
}> | ||
): string[] { | ||
return cleanLogs(spy); | ||
} | ||
|
||
export function tryError() { | ||
try { | ||
throw new Error("This is an error"); | ||
} catch (e) { | ||
return e as Error; | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters