Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
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 514 weekly downloads. As such, eslint-plugin-cypress-best-practices popularity was classified as not 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.