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: add mocha instructions to readme #181

Merged
merged 1 commit into from
Apr 22, 2024

Conversation

MikeMcC399
Copy link
Collaborator

Issue

Users have requested linting support to detect .only and .skip constructs in Cypress test specs and have submitted issues and PRs to have these rules built in to eslint-plugin-cypress. Adding these rules into the Cypress plugin would however duplicate the following existing working and comprehensive rules in eslint-plugin-mocha:

  • mocha/no-exclusive-tests to warn about the use of describe.only, it.only, suite.only, test.only, context.only and specify.only within the source code.
  • mocha/no-skipped-tests to warn about the use of describe.skip, it.skip, suite.skip, test.skip, context.skip, specify.skip, xdescribe, xit, xcontext and xspecify within the source code.

The alternative to adding the rules to eslint-plugin-cypress is to install and use eslint-plugin-mocha together with eslint-plugin-cypress.

Change

A section is added to the README to describe how to use the eslint-plugin-mocha plugin together with the eslint-plugin-cypress plugin in order to detect .only and .skip usage.

Verification

Verify using the working example of eslint-plugin-cypress and eslint-plugin-mocha in the cypress-io/cypress-example-kitchensink repo (see .eslintrc for the ESLint 8.x config file).

git clone https://github.com/cypress-io/cypress-example-kitchensink
cd cypress-example-kitchensink
npm ci
npm install eslint@8 eslint-plugin-mocha@latest -D

Modify the file cypress/e2e/2-advanced-examples/actions.cy.js to add an exclusive test and a skipped test:

  • Change context to context.only
  • Change the first occurence of it to it.skip

and execute:

npx eslint cypress

confirm that linting errors are reported:

$ npx eslint cypress

   3:9  error    Unexpected exclusive mocha test  mocha/no-exclusive-tests
  10:6  warning  Unexpected skipped mocha test    mocha/no-skipped-tests

✖ 2 problems (1 error, 1 warning)

@cypress-app-bot
Copy link

@MikeMcC399 MikeMcC399 marked this pull request as ready for review April 21, 2024 15:54
@MikeMcC399

This comment was marked as outdated.

Copy link
Member

@jennifer-shehane jennifer-shehane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great to include

@jennifer-shehane jennifer-shehane merged commit c1a540d into cypress-io:master Apr 22, 2024
6 checks passed
@MikeMcC399 MikeMcC399 deleted the mocha-instructions branch April 22, 2024 13:39
@cypress-app-bot
Copy link

🎉 This PR is included in version 3.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.only and .skip rule needs
3 participants