Based off jQuery, Mocha and Chai with many of the same selector and test interfaces
Queues all the commands async so use .then() and such to handle conditionals
Supports ES6 and importing packages out of the box
// Each method is equivalent to its jQuery counterpart. Use what you know!cy.get('#main-content').find('.article').children('img[src^="/static"]').first()
./node_modules/.bin/cypressopen
Yup no imports or anything needed
/* global describe it cy */describe('My First Test', () => {it('finds the content "type"', () => {cy.visit('https://example.cypress.io')cy.get('.main').contains('New Post')cy.contains('Like article')cy.url().should('include','/commands/actions')cy.get('.action-email').type('fake@email.com').should('have.value','fake@email.com') })})
cy.get(':checkbox').should('be.disabled')cy.get('form').should('have.class','form-horizontal')cy.get('input').should('not.have.value','US')cy// Find the el with id 'some-link'.get('#some-link').then(($myElement) => {// ...massage the subject with some arbitrary code, grab its href propertyconsthref=$myElement.prop('href')// strip out the 'hash' character and everything after itreturnhref.replace(/(#.*)/,'') }).then((href) => {// href is now the new subject which we can work with now })
describe('Hooks', () => {before(() => {// runs once before all tests in the block })beforeEach(() => {// runs before each test in the block })afterEach(() => {// runs after each test in the block })after(() => {// runs once after all tests in the block })})
Act on A Subject Sync with .then()
cy// Find the el with id 'some-link'.get('#some-link').then(($myElement) => {// ...massage the subject with some arbitrary code// grab its href propertyconsthref=$myElement.prop('href')// strip out the 'hash' character and everything after itreturnhref.replace(/(#.*)/,'') }).then((href) => {// href is now the new subject// which we can work with now })