UNPKG

cra-template-pi

Version:

A quick start Create React App with many auto implemented features

42 lines (39 loc) 1.4 kB
import '@testing-library/cypress/add-commands' import { generatePath } from 'react-router-dom' import { counterActions } from '../../src/store/reducers/counterReducer' import { TRoutePath } from '../../src/constants/routePaths' // *********************************************** // This example commands.js shows you how to // create various custom commands and overwrite // existing commands. // // For more comprehensive examples of custom // commands please read more here: // https://on.cypress.io/custom-commands // *********************************************** // // // -- This is a parent command -- // Cypress.Commands.add("login", (email, password) => { ... }) // // // -- This is a child command -- // Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) // // // -- This is a dual command -- // Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) // // // -- This will overwrite an existing command -- // Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) Cypress.Commands.add('visitRoute', (routePath: TRoutePath, options, ...rest) => cy.visit(generatePath(routePath, options), ...rest) ) Cypress.Commands.add('incrementCounterReducer', (incrementBy = 3) => { cy.window() .its('store') .then(({ dispatch }) => { dispatch(counterActions.incrementBy(incrementBy)) }) })