{ "version": 3, "sources": ["../../cypress-wait-until/src/index.js"], "sourcesContent": ["'use strict'\n\nconst logCommand = ({ options, originalOptions }) => {\n if (options.log) {\n options.logger({\n name: options.description,\n message: options.customMessage,\n consoleProps: () => originalOptions,\n })\n }\n}\nconst logCommandCheck = ({ result, options, originalOptions }) => {\n if (!options.log || !options.verbose) return\n\n const message = [result]\n if (options.customCheckMessage) {\n message.unshift(options.customCheckMessage)\n }\n options.logger({\n name: options.description,\n message,\n consoleProps: () => originalOptions,\n })\n}\n\nconst waitUntil = (subject, checkFunction, originalOptions = {}) => {\n if (!(checkFunction instanceof Function)) {\n throw new Error('`checkFunction` parameter should be a function. Found: ' + checkFunction)\n }\n\n const defaultOptions = {\n // base options\n interval: 200,\n timeout: 5000,\n errorMsg: 'Timed out retrying',\n\n // log options\n description: 'waitUntil',\n log: true,\n customMessage: undefined,\n logger: Cypress.log,\n verbose: false,\n customCheckMessage: undefined,\n }\n const options = { ...defaultOptions, ...originalOptions }\n\n // filter out a falsy passed \"customMessage\" value\n options.customMessage = [options.customMessage, originalOptions].filter(Boolean)\n\n let retries = Math.floor(options.timeout / options.interval)\n\n logCommand({ options, originalOptions })\n\n const check = (result) => {\n logCommandCheck({ result, options, originalOptions })\n if (result) {\n return result\n }\n if (retries < 1) {\n const msg =\n options.errorMsg instanceof Function ? options.errorMsg(result, options) : options.errorMsg\n throw new Error(msg)\n }\n cy.wait(options.interval, { log: false }).then(() => {\n retries--\n return resolveValue()\n })\n }\n\n const resolveValue = () => {\n const result = checkFunction(subject)\n\n const isAPromise = Boolean(result && result.then)\n if (isAPromise) {\n return result.then(check)\n } else {\n return check(result)\n }\n }\n\n return resolveValue()\n}\n\nCypress.Commands.add('waitUntil', { prevSubject: 'optional' }, waitUntil)\n"], "mappings": ";AAEA,IAAM,aAAa,CAAC,EAAE,SAAS,gBAAgB,MAAM;AACnD,MAAI,QAAQ,KAAK;AACf,YAAQ,OAAO;AAAA,MACb,MAAM,QAAQ;AAAA,MACd,SAA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