@chtsinc/ch-playwright-report
Version:
Custom Playwright Reporter that logs test and execution results to MongoDB
28 lines • 1.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getFirstAnnotationDescription = getFirstAnnotationDescription;
exports.getAnnotationDescriptions = getAnnotationDescriptions;
/**
* Return the description of the first annotation matching annotationType.
* @param annotations - Playwright’s annotations array (e.g. from TestInfo.annotations)
* @param annotationType - the annotation “type” to look for
* @returns the first matching description, or undefined if none found
*/
function getFirstAnnotationDescription(annotations, annotationType) {
const ann = annotations.find(a => a.type === annotationType);
return ann?.description;
}
/**
* Collect all descriptions for annotations of a given type.
* @param annotations - Playwright’s annotations array
* @param annotationType - the annotation “type” to filter by
* @returns an array of non-null descriptions
*/
function getAnnotationDescriptions(annotations, annotationType) {
return annotations
.filter(
// narrows so TS knows description is a string
(a) => a.type === annotationType && typeof a.description === "string")
.map(a => a.description);
}
//# sourceMappingURL=test-annotations-util.js.map