orphic-cypress
Version:
Set of utilities and typescript transformers to cover storybook stories with cypress component tests
18 lines • 800 B
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.mockToCyIntercept = void 0;
/**
* Turn mockData intended for storybook plugin storybook-addon-mock
* into cypress intercepts. Very likely to be used in a beforeEach.
* Aliases as the url provided for each mock. Nothing crazy happening
* here, you could just write `cy.intercept`s for non-storybook component
* tests, or nbd to have ones that are redundant of mockData
*/
const mockToCyIntercept = (mockData) => mockData.forEach(({ response, status, url, method, alias }) => {
cy.intercept(method, url, {
body: response,
statusCode: status,
}).as(alias !== null && alias !== void 0 ? alias : url);
});
exports.mockToCyIntercept = mockToCyIntercept;
//# sourceMappingURL=intercept.js.map
;