3.0.1 • Published 4 months ago

cypress-tools v3.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

NPM

CI

cypress-tools

This is a repo containg some simple Cypress commands, intended for use as simplifying building blocks for more complicated/realistic testing scenarios. The aim is that using these commands makes writing, reading and debugging tests much easier.

Please note, this repo is in no way affliated or approved by Cypress, it is purely to help me use Cypress for the various testing projects I am involved with. Cypress is an awesome testing framework for modern web applications, if you haven't then you should definietly check them out: https://www.cypress.io/

Getting started

Add this module to your project using npm install cypress-tools --save-dev and then import this module in your Cypress support file (usually found at ./cypress/support/index.js). Alternatively, you can import it in each test file where it's needed if that better suits your usage.

Most of the commands use the default selector data-testid to find and assert on elements. This means that as long as you are using the data-testid tag on the elements you are testing, you only need to pass the value of the tag, instead of '[data-testid="some-data-testid"]'. To choose a different value, add the defaultSelector field to your Cypress env configuration:

// cypress.config.ts
{
  e2e: {
    env: {
      defaultSelector: 'data-cy'
    }
  },
  ...
}

Or in a specific test file:

// example.cy.ts
Cypress.env('defaultSelector', 'data-cy')

describe('tests' () => {
  ...
})

Commands available

More info about these commands and their usage is available via their type definitions

Command NameDescription
assertAttrAssert the attributes of an element
assertCssAssert the CSS of an element
assertVisAssert the visibility of an element
checkTagCheck a checkbox
clickTagClick an element
countGet the count of an element by tag
existsCheck an element exists
getTagGet an element
selectTagSelect from a dropdown
textGet the text from an element
typeTextType into an element
3.0.1

4 months ago

2.1.1-next.0

4 months ago

3.0.0

4 months ago

2.1.1-next.1.0

4 months ago

2.1.0

4 months ago

2.0.0

4 months ago

1.5.0

3 years ago

1.4.1

3 years ago

1.3.2

3 years ago

1.4.0

3 years ago

1.3.1

3 years ago

1.3.0

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago