UNPKG

ui-omakase-framework

Version:

A comprehensive E2E testing framework library with pre-built Cucumber step definitions and utilities for web automation testing

23 lines (22 loc) 778 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.interceptResponse = void 0; const interceptResponse = async (page, mockServerKey, mockConfigKey, mockPayloadKey, { hostsConfig, mocksConfig, mockPayloadMappings }) => { const mockServerHostURL = hostsConfig[mockServerKey]; const mockServerRoute = mocksConfig[mockConfigKey]; const mockServerPayload = mockPayloadMappings[mockPayloadKey]; if (!mockServerPayload) { throw Error(`🧨 Unable to find the ${mockPayloadKey} payload json file 🧨`); } await page.route(`${mockServerHostURL}${mockServerRoute}`, route => route.fulfill({ contentType: 'application/json', body: JSON.stringify(mockServerPayload) })); }; exports.interceptResponse = interceptResponse;