
Security News
vlt Launches "reproduce": A New Tool Challenging the Limits of Package Provenance
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
eslint-plugin-cypress-best-practices
Advanced tools
An ESLint plugin for your Cypress tests.
Note: If you installed ESLint globally then you must also install eslint-plugin-cypress-best-practices
globally.
npm install eslint-plugin-cypress-best-practices --save-dev
or
yarn add eslint-plugin-cypress-best-practices --dev
Add an .eslintrc.json
file to your cypress
directory with the following:
{
"plugins": [
"cypress-best-practices"
]
}
You can add rules:
{
"rules": {
"cypress-best-practices/enforce-page-object-model": "error",
"cypress-best-practices/no-duplicate-selectors": "error",
"cypress-best-practices/no-simple-selectors": "warn",
}
}
enforce-page-object-model
The cy.get command should be limited to page object files, any cy.get with a string literal will be detected with some minor exclusions.
it('use literal string in cy.get', () => {
...
/**
* Will throw 'No literal string selectors inside test files.'
*/
cy.get('#form > button:nth-child(1)').click()
...
})
no-duplicate-selectors
This applies to the page object model, when a return expression contains a cy.get() action, it will compared with other return expressions to avoid duplicates.
class HomePage {
get loginButton() {
return cy.get('#form > .actions > nth-child(1)');
}
get loginBtn() {
/**
* Will throw 'No duplicate Cypress selectors.'
*/
return cy.get('#form > .actions > nth-child(1)');
}
}
no-simple-selectors
Any literal string selector that is only alphanumeric will be flagged.
class HomePage {
get loginButton() {
return cy.get('#form > .actions > nth-child(1)');
}
get productImage() {
/**
* Will throw 'No generic selectors.'
*/
return cy.get('img');
}
}
To add a new rule:
Use the following commit message conventions: https://github.com/semantic-release/semantic-release#commit-message-format
FAQs
An ESLint plugin for your Cypress tests.
The npm package eslint-plugin-cypress-best-practices receives a total of 2,399 weekly downloads. As such, eslint-plugin-cypress-best-practices popularity was classified as popular.
We found that eslint-plugin-cypress-best-practices demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
vlt's new "reproduce" tool verifies npm packages against their source code, outperforming traditional provenance adoption in the JavaScript ecosystem.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.