'use strict'; /// /** * Repeats a test multiple times and skips other tests. * @param times - The number of times to repeat the test. * @param options.rename - Whether to rename the test with an index. */ const repeatTest = (times, options) => { const testDescriptor = Object.getOwnPropertyDescriptor(globalThis, 'test'); if (!testDescriptor) return; const tests = []; Object.defineProperty(globalThis, 'test', { get() { Object.defineProperty(globalThis, 'test', testDescriptor); const makeTest = testDescriptor.get; const testInstance = makeTest(); function proxyInstance(name, fn) { for (let i = 1; i <= times; i++) { const instance = makeTest(); const testName = (options?.rename ?? true) ? `${name} ${i}` : name; tests.push(instance.only(testName, fn)); } testInstance(name, fn); return proxyInstance; } const skip = new Set(['prototype', 'length', 'name']); for (const [property, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(testInstance))) { if (skip.has(property)) continue; if (descriptor.get === undefined) { Object.defineProperty(proxyInstance, property, { get() { return testInstance[property]; }, }); } else { Object.defineProperty(proxyInstance, property, { get: () => { const method = descriptor.get?.(); if (method.name !== 'apiOrigin') { return (...args) => { method(...args); tests.forEach((test) => test[property](...args)); return proxyInstance; }; } else { tests.forEach((test) => test[property]()); return proxyInstance; } }, }); } } return proxyInstance; }, }); }; module.exports = repeatTest; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5janMiLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyIvLy8gPHJlZmVyZW5jZSB0eXBlcz1cInRlc3RjYWZlXCIgLz5cblxuLyoqXG4gKiBSZXBlYXRzIGEgdGVzdCBtdWx0aXBsZSB0aW1lcyBhbmQgc2tpcHMgb3RoZXIgdGVzdHMuXG4gKiBAcGFyYW0gdGltZXMgLSBUaGUgbnVtYmVyIG9mIHRpbWVzIHRvIHJlcGVhdCB0aGUgdGVzdC5cbiAqIEBwYXJhbSBvcHRpb25zLnJlbmFtZSAtIFdoZXRoZXIgdG8gcmVuYW1lIHRoZSB0ZXN0IHdpdGggYW4gaW5kZX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BTZXQoWydwcm90b3R5cGUnLCAnbGVuZ3RoJywgJ25hbWUnXSk7XG4gICAgICBmb3IgKGNvbnN0IFtwcm9wZXJ0eSwgZGVzY3JpcHRvcl0gb2YgT2JqZWN0LmVudHJpZXMoT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcnModGVzdEluc3RhbmNlKSkpIHtcbiAgICAgICAgaWYgKHNraXAuaGFzKHByb3BlcnR5KSkgY29udGludWU7XG4gICAgICAgIGlmIChkZXNjcmlwdG9yLmdldCA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KHByb3h5SW5zdGFuY2UsIHByb3BlcnR5LCB7XG4gICAgICAgICAgICBnZXQoKSB7XG4gICAgICAgICAgICAgIHJldHVybiB0ZXN0SW5zdGFuY2VbcHJvcGVydHldO1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkocHJveHlJbnN0YW5jZSwgcHJvcGVydHksIHtcbiAgICAgICAgICAgIGdldDogKCkgPT4ge1xuICAgICAgICAgICAgICBjb25zdCBtZXRob2QgPSBkZXNjcmlwdG9yLmdldD8uKCk7XG4gICAgICAgICAgICAgIGlmIChtZXRob2QubmFtZSAhPT0gJ2FwaU9yaWdpbicpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4gKC4uLmFyZ3M6IGFueVtdKSA9PiB7XG4gICAgICAgICAgICAgICAgICBtZXRob2QoLi4uYXJncyk7XG4gICAgICAgICAgICAgICAgICB0ZXN0cy5mb3JFYWNoKCh0ZXN0OiBhbnkpID0+IHRlc3RbcHJvcGVydHldKC4uLmFyZ3MpKTtcbiAgICAgICAgICAgICAgICAgIHJldHVybiBwcm94eUluc3RhbmNlO1xuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgdGVzd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