Skip to content

Instantly share code, notes, and snippets.

@ivan-hilckov
Created October 25, 2018 15:22
Show Gist options
  • Save ivan-hilckov/88b7d3598f2f7602f99a526939ec5c18 to your computer and use it in GitHub Desktop.
Save ivan-hilckov/88b7d3598f2f7602f99a526939ec5c18 to your computer and use it in GitHub Desktop.
Общие куски для всех тестов
import { URLS, PATH_NAME } from '../../src/constants/path'
import ENDPOINTS from '../../src/constants/endpoints'
// ***********************************************
// 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('signin', (email = '[email protected]', password = 'Not1pass1') => {
return cy.request({
method: 'POST',
url: ENDPOINTS.login(),
body: { email, password },
})
})
Cypress.Commands.add('project', projectId => {
cy.server()
cy.route('/api/project/*/').as('getProject')
cy.route('/api/labels/*/').as('getLabels')
cy.route('/api/project-unit-attach/?project_unit=*').as('getCurrentUnit')
cy.visit(URLS[PATH_NAME.project]({ projectId })).wait(['@getProject', '@getLabels', '@getCurrentUnit'])
})
Cypress.Commands.add('layer', projectId => {
cy.server()
cy.route('/api/project/*/').as('getProject')
cy.route('/api/labels/*/').as('getLabels')
cy.route('/api/project-unit-attach/?project_unit=*').as('getCurrentUnit')
cy.visit(URLS[PATH_NAME.layer]({ projectId })).wait(['@getProject', '@getLabels', '@getCurrentUnit'])
})
Cypress.Commands.add('xyz', projectId => {
cy.server()
cy.route('/api/project/*/').as('getProject')
cy.visit(URLS[PATH_NAME.layer]({ projectId })).wait('@getProject')
})
//
//
// -- 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 is will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment