-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
pavel.butuzov
committed
Nov 6, 2024
1 parent
5e4f88f
commit f2a082e
Showing
3 changed files
with
56 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { TestError } from "@playwright/test/reporter"; | ||
import { Step } from "testit-js-commons"; | ||
import { Status } from "./converter"; | ||
|
||
export type StatusDetails = { | ||
message?: string; | ||
trace?: string; | ||
}; | ||
|
||
export function getStatusDetails (error: TestError): StatusDetails { | ||
const message = error.message && stripAscii(error.message); | ||
let trace = error.stack && stripAscii(error.stack); | ||
if (trace && message && trace.startsWith(`Error: ${message}`)) { | ||
trace = trace.substr(message.length + "Error: ".length); | ||
} | ||
return { | ||
message: message, | ||
trace: trace, | ||
}; | ||
}; | ||
|
||
export function isAllStepsWithPassedOutcome(steps: Step[]): boolean { | ||
return !steps.find((step: Step) => step.outcome === Status.FAILED); | ||
} | ||
|
||
export function stripAscii (str: string): string { | ||
return str.replace(asciiRegex, ""); | ||
}; | ||
|
||
const asciiRegex = new RegExp( | ||
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))", | ||
"g", | ||
); |