You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Contributing to cypress-io/eslint-plugin-cypress
2
+
3
+
Thanks for taking the time to contribute! :smile:
4
+
5
+
To add a new rule:
6
+
* Fork and clone this repository
7
+
* Generate a new rule (a [yeoman generator](https://github.com/eslint/generator-eslint) is available)
8
+
* Write test scenarios then implement logic
9
+
* Describe the rule in the generated `docs` file
10
+
* Run `npm test` to run [Jest](https://jestjs.io/) or
11
+
* Run `npm start` to run [Jest](https://jestjs.io/) in [watchAll](https://jestjs.io/docs/cli#--watchall) mode where it remains active and reruns when source changes are made
12
+
* Make sure all tests are passing
13
+
* Add the rule to the [README](README.md) file
14
+
* Create a PR
15
+
16
+
Use the following commit message conventions: https://github.com/semantic-release/semantic-release#commit-message-format
|[unsafe-to-chain-command](docs/rules/unsafe-to-chain-command.md)| disallow actions within chains | ✅ |
134
+
135
+
<!-- end auto-generated rules list -->
136
+
137
+
## Mocha and Chai
138
+
139
+
Cypress is built on top of [Mocha](https://on.cypress.io/guides/references/bundled-libraries#Mocha) and [Chai](https://on.cypress.io/guides/references/bundled-libraries#Chai). See the following sections for information on using ESLint plugins [eslint-plugin-mocha](https://www.npmjs.com/package/eslint-plugin-mocha) and [eslint-plugin-chai-friendly](https://www.npmjs.com/package/eslint-plugin-chai-friendly) together with `eslint-plugin-cypress`.
140
+
141
+
## Mocha `.only` and `.skip`
142
+
143
+
During test spec development, [Mocha exclusive tests](https://mochajs.org/#exclusive-tests)`.only` or [Mocha inclusive tests](https://mochajs.org/#inclusive-tests)`.skip` may be used to control which tests are executed, as described in the Cypress documentation [Excluding and Including Tests](https://on.cypress.io/guides/core-concepts/writing-and-organizing-tests#Excluding-and-Including-Tests). To apply corresponding rules, you can install and use [eslint-plugin-mocha](https://www.npmjs.com/package/eslint-plugin-mocha). The rule [mocha/no-exclusive-tests](https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-exclusive-tests.md) detects the use of `.only` and the [mocha/no-skipped-tests](https://github.com/lo1tuma/eslint-plugin-mocha/blob/main/docs/rules/no-skipped-tests.md) rule detects the use of `.skip`:
144
+
145
+
```sh
146
+
npm install --save-dev eslint-plugin-mocha
147
+
```
148
+
149
+
In your `.eslintrc.json`:
150
+
151
+
```json
152
+
{
153
+
"plugins": [
154
+
"cypress",
155
+
"mocha"
156
+
],
157
+
"rules": {
158
+
"mocha/no-exclusive-tests": "warn",
159
+
"mocha/no-skipped-tests": "warn"
160
+
}
161
+
}
162
+
```
116
163
117
-
**NOTE**: These rules currently require eslint 5.0 or greater. If you would like support added for eslint 4.x, please 👍 [this issue](https://github.com/cypress-io/eslint-plugin-cypress/issues/14).
164
+
Or you can simply use the `cypress/recommended` and `mocha/recommended` configurations together, for example:
Copy file name to clipboardExpand all lines: docs/rules/assertion-before-screenshot.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,19 +1,22 @@
1
-
## Assertion Before Screenshot
1
+
#Require screenshots to be preceded by an assertion (`cypress/assertion-before-screenshot`)
2
2
3
+
<!-- end auto-generated rule header -->
3
4
If you take screenshots without assertions then you may get different screenshots depending on timing.
4
5
5
6
For example, if clicking a button makes some network calls and upon success, renders something, then the screenshot may sometimes have the new render and sometimes not.
6
7
8
+
## Rule Details
9
+
7
10
This rule checks there is an assertion making sure your application state is correct before doing a screenshot. This makes sure the result of the screenshot will be consistent.
0 commit comments