UNPKG

e2ed

Version:

E2E testing framework over Playwright

32 lines (31 loc) 1.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getResponse = void 0; const fullMocks_1 = require("../../context/fullMocks"); const fullMocks_2 = require("../fullMocks"); const log_1 = require("../log"); const oneTryOfRequest_1 = require("./oneTryOfRequest"); /** * Get `ResponseWithRequest` from one try of request. * @internal */ const getResponse = async (options) => { const { isNeedRetry, url, ...oneTryOfRequestOptions } = options; const { fullLogParams, response } = await (0, oneTryOfRequest_1.oneTryOfRequest)(oneTryOfRequestOptions); const needRetry = await isNeedRetry(response); (0, log_1.log)(`Got a response to the request to ${url}`, { ...fullLogParams, logEventStatus: needRetry ? "failed" /* LogEventStatus.Failed */ : "passed" /* LogEventStatus.Passed */, needRetry, response, }, 8 /* LogEventType.InternalUtil */); if (needRetry === false) { const fullMocksState = (0, fullMocks_1.getFullMocksState)(); if (fullMocksState !== undefined) { (0, fullMocks_2.writeResponseToFullMocks)(response); } return response; } return undefined; }; exports.getResponse = getResponse;