ScuttleBot

scuttlebot / tests / e2e / node_modules / playwright / lib / common / poolBuilder.js
Source Blame History 85 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 poolBuilder_exports = {};
f7eb47b… lmata 20 __export(poolBuilder_exports, {
f7eb47b… lmata 21 PoolBuilder: () => PoolBuilder
f7eb47b… lmata 22 });
f7eb47b… lmata 23 module.exports = __toCommonJS(poolBuilder_exports);
f7eb47b… lmata 24 var import_fixtures = require("./fixtures");
f7eb47b… lmata 25 var import_util = require("../util");
f7eb47b… lmata 26 class PoolBuilder {
f7eb47b… lmata 27 constructor(type, project) {
f7eb47b… lmata 28 this._testTypePools = /* @__PURE__ */ new Map();
f7eb47b… lmata 29 this._type = type;
f7eb47b… lmata 30 this._project = project;
f7eb47b… lmata 31 }
f7eb47b… lmata 32 static createForLoader() {
f7eb47b… lmata 33 return new PoolBuilder("loader");
f7eb47b… lmata 34 }
f7eb47b… lmata 35 static createForWorker(project) {
f7eb47b… lmata 36 return new PoolBuilder("worker", project);
f7eb47b… lmata 37 }
f7eb47b… lmata 38 buildPools(suite, testErrors) {
f7eb47b… lmata 39 suite.forEachTest((test) => {
f7eb47b… lmata 40 const pool = this._buildPoolForTest(test, testErrors);
f7eb47b… lmata 41 if (this._type === "loader")
f7eb47b… lmata 42 test._poolDigest = pool.digest;
f7eb47b… lmata 43 if (this._type === "worker")
f7eb47b… lmata 44 test._pool = pool;
f7eb47b… lmata 45 });
f7eb47b… lmata 46 }
f7eb47b… lmata 47 _buildPoolForTest(test, testErrors) {
f7eb47b… lmata 48 let pool = this._buildTestTypePool(test._testType, testErrors);
f7eb47b… lmata 49 const parents = [];
f7eb47b… lmata 50 for (let parent = test.parent; parent; parent = parent.parent)
f7eb47b… lmata 51 parents.push(parent);
f7eb47b… lmata 52 parents.reverse();
f7eb47b… lmata 53 for (const parent of parents) {
f7eb47b… lmata 54 if (parent._use.length)
f7eb47b… lmata 55 pool = new import_fixtures.FixturePool(parent._use, (e) => this._handleLoadError(e, testErrors), pool, parent._type === "describe");
f7eb47b… lmata 56 for (const hook of parent._hooks)
f7eb47b… lmata 57 pool.validateFunction(hook.fn, hook.type + " hook", hook.location);
f7eb47b… lmata 58 for (const modifier of parent._modifiers)
f7eb47b… lmata 59 pool.validateFunction(modifier.fn, modifier.type + " modifier", modifier.location);
f7eb47b… lmata 60 }
f7eb47b… lmata 61 pool.validateFunction(test.fn, "Test", test.location);
f7eb47b… lmata 62 return pool;
f7eb47b… lmata 63 }
f7eb47b… lmata 64 _buildTestTypePool(testType, testErrors) {
f7eb47b… lmata 65 if (!this._testTypePools.has(testType)) {
f7eb47b… lmata 66 const optionOverrides = {
f7eb47b… lmata 67 overrides: this._project?.project?.use ?? {},
f7eb47b… lmata 68 location: { file: `project#${this._project?.id}`, line: 1, column: 1 }
f7eb47b… lmata 69 };
f7eb47b… lmata 70 const pool = new import_fixtures.FixturePool(testType.fixtures, (e) => this._handleLoadError(e, testErrors), void 0, void 0, optionOverrides);
f7eb47b… lmata 71 this._testTypePools.set(testType, pool);
f7eb47b… lmata 72 }
f7eb47b… lmata 73 return this._testTypePools.get(testType);
f7eb47b… lmata 74 }
f7eb47b… lmata 75 _handleLoadError(e, testErrors) {
f7eb47b… lmata 76 if (testErrors)
f7eb47b… lmata 77 testErrors.push(e);
f7eb47b… lmata 78 else
f7eb47b… lmata 79 throw new Error(`${(0, import_util.formatLocation)(e.location)}: ${e.message}`);
f7eb47b… lmata 80 }
f7eb47b… lmata 81 }
f7eb47b… lmata 82 // Annotate the CommonJS export names for ESM import in node:
f7eb47b… lmata 83 0 && (module.exports = {
f7eb47b… lmata 84 PoolBuilder
f7eb47b… lmata 85 });

Keyboard Shortcuts

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