ScuttleBot

scuttlebot / tests / e2e / node_modules / playwright / lib / runner / failureTracker.js
Source Blame History 72 lines
f7eb47b… lmata 1 "use strict";
f7eb47b… lmata 2 var __defProp = Object.defineProperty;
f7eb47b… lmata 3 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
f7eb47b… lmata 4 var __getOwnPropNames = Object.getOwnPropertyNames;
f7eb47b… lmata 5 var __hasOwnProp = Object.prototype.hasOwnProperty;
f7eb47b… lmata 6 var __export = (target, all) => {
f7eb47b… lmata 7 for (var name in all)
f7eb47b… lmata 8 __defProp(target, name, { get: all[name], enumerable: true });
f7eb47b… lmata 9 };
f7eb47b… lmata 10 var __copyProps = (to, from, except, desc) => {
f7eb47b… lmata 11 if (from && typeof from === "object" || typeof from === "function") {
f7eb47b… lmata 12 for (let key of __getOwnPropNames(from))
f7eb47b… lmata 13 if (!__hasOwnProp.call(to, key) && key !== except)
f7eb47b… lmata 14 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
f7eb47b… lmata 15 }
f7eb47b… lmata 16 return to;
f7eb47b… lmata 17 };
f7eb47b… lmata 18 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
f7eb47b… lmata 19 var failureTracker_exports = {};
f7eb47b… lmata 20 __export(failureTracker_exports, {
f7eb47b… lmata 21 FailureTracker: () => FailureTracker
f7eb47b… lmata 22 });
f7eb47b… lmata 23 module.exports = __toCommonJS(failureTracker_exports);
f7eb47b… lmata 24 class FailureTracker {
f7eb47b… lmata 25 constructor(config, options) {
f7eb47b… lmata 26 this._failureCount = 0;
f7eb47b… lmata 27 this._hasWorkerErrors = false;
f7eb47b… lmata 28 this._topLevelProjects = [];
f7eb47b… lmata 29 this._config = config;
f7eb47b… lmata 30 this._pauseOnError = !!options?.pauseOnError;
f7eb47b… lmata 31 this._pauseAtEnd = !!options?.pauseAtEnd;
f7eb47b… lmata 32 }
f7eb47b… lmata 33 onRootSuite(rootSuite, topLevelProjects) {
f7eb47b… lmata 34 this._rootSuite = rootSuite;
f7eb47b… lmata 35 this._topLevelProjects = topLevelProjects;
f7eb47b… lmata 36 }
f7eb47b… lmata 37 onTestEnd(test, result) {
f7eb47b… lmata 38 if (test.outcome() === "unexpected" && test.results.length > test.retries)
f7eb47b… lmata 39 ++this._failureCount;
f7eb47b… lmata 40 }
f7eb47b… lmata 41 onWorkerError() {
f7eb47b… lmata 42 this._hasWorkerErrors = true;
f7eb47b… lmata 43 }
f7eb47b… lmata 44 pauseOnError() {
f7eb47b… lmata 45 return this._pauseOnError;
f7eb47b… lmata 46 }
f7eb47b… lmata 47 pauseAtEnd(inProject) {
f7eb47b… lmata 48 return this._topLevelProjects.includes(inProject) && this._pauseAtEnd;
f7eb47b… lmata 49 }
f7eb47b… lmata 50 hasReachedMaxFailures() {
f7eb47b… lmata 51 return this.maxFailures() > 0 && this._failureCount >= this.maxFailures();
f7eb47b… lmata 52 }
f7eb47b… lmata 53 hasWorkerErrors() {
f7eb47b… lmata 54 return this._hasWorkerErrors;
f7eb47b… lmata 55 }
f7eb47b… lmata 56 result() {
f7eb47b… lmata 57 return this._hasWorkerErrors || this.hasReachedMaxFailures() || this.hasFailedTests() || this._config.failOnFlakyTests && this.hasFlakyTests() ? "failed" : "passed";
f7eb47b… lmata 58 }
f7eb47b… lmata 59 hasFailedTests() {
f7eb47b… lmata 60 return this._rootSuite?.allTests().some((test) => !test.ok());
f7eb47b… lmata 61 }
f7eb47b… lmata 62 hasFlakyTests() {
f7eb47b… lmata 63 return this._rootSuite?.allTests().some((test) => test.outcome() === "flaky");
f7eb47b… lmata 64 }
f7eb47b… lmata 65 maxFailures() {
f7eb47b… lmata 66 return this._config.config.maxFailures;
f7eb47b… lmata 67 }
f7eb47b… lmata 68 }
f7eb47b… lmata 69 // Annotate the CommonJS export names for ESM import in node:
f7eb47b… lmata 70 0 && (module.exports = {
f7eb47b… lmata 71 FailureTracker
f7eb47b… lmata 72 });

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button