Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: cy script conventions #36

Closed
jennifer-shehane opened this issue Sep 6, 2017 · 0 comments
Closed

Docs: cy script conventions #36

jennifer-shehane opened this issue Sep 6, 2017 · 0 comments

Comments

@jennifer-shehane
Copy link
Member

@brian-mann commented on Mon Jun 12 2017

WIP

side + below

cy.visit('/')

cy
.contains('Guides')
.click()
.contains('h1', 'Why Cypress')
.find('.bar')
.should('have.class', 'baz')

cy
.url()
.should('eq', 'foo')
.then(() => {
  cy
  .get('form')
  .submit()
})

always below

cy
.visit('/')

cy
.contains('Guides')
.click()
.contains('h1', 'Why Cypress')
.find('.bar')
.should('have.class', 'baz')

cy
.url()
.should('eq', 'foo')
.then(() => {
  cy
  .get('form')
  .submit()
})

multi line indented

cy.visit('/')

cy
  .contains('Guides')
  .click()
  .contains('h1', 'Why Cypress')
  .find('.bar')
  .should('have.class', 'baz')

cy
  .url()
  .should('eq', 'foo')
  .then(() => {
    cy
      .get('form')
      .submit()
  })

always indented

cy
  .visit('/')

cy
  .contains('Guides')
  .click()
  .contains('h1', 'Why Cypress')
  .find('.bar')
  .should('have.class', 'baz')

cy
  .url()
  .should('eq', 'foo')
  .then(() => {
    cy
      .get('form')
      .submit()
  })

multi line - to the side

cy.visit('/')

cy.contains('Guides')
  .click()
  .contains('h1', 'Why Cypress')
  .find('.bar')
  .should('have.class', 'baz')

cy.url()
  .should('eq', 'foo')
  .then(() => {
    cy.get('form')
      .submit()
  })

@jennifer-shehane commented on Wed Jun 14 2017

There are actually other cases where some code examples are chained on one line. This is how I would write this example:

cy.visit('/')
cy.contains('Guides').click()
  .contains('h1', 'Why Cypress').find('.bar').should('have.class', 'baz')
cy.url().should('eq', 'foo').then(() => {
  cy.get('form').submit()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant