Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
cypress-nhover
Advanced tools
Add nhover (NativeHover) and nmove (NativeMove) command to Cypress.io test runner. Use CDP in background to create a "real" hover on elements in a puppeteer'ish way.
npm install -D cypress-nhover
Then include in your project's cypress/support/index.js
require('cypress-nhover')
After installation, your cy
object will have .nhover
child command.
.nhover
command must be chained from a command yielding an HTMLElement.
it('element css change background color because of :hover pseudoclass', () => {
cy.get('#hoverButton')
.should('have.css', 'background-color', 'rgb(0, 0, 255)');
cy.get('#hoverButton')
.nhover()
.should('have.css', 'background-color', 'rgb(255, 0, 0)');
})
If an element isn't visible into the view, .nhover
will try to scroll onto it before trying to hovering it.
So, the two following commands will produce the same result:
it('explicitly scollIntoView for hovering', () => {
cy.get('#hoverButton')
.scrollIntoView()
.nhover()
.should('have.css', 'background-color', 'rgb(255, 0, 0)');
})
// Is equivalent to:
it('dont explicilty scollIntoView', () => {
cy.get('#hoverButton')
.nhover()
.should('have.css', 'background-color', 'rgb(255, 0, 0)');
})
note: This hover implementation work more or less in the same way as the one implemented by puppeteer and discussed here
This package come with another new command: nmove
. The main goal of .nmove
is to provide an easy way to "unhover" an
element hovered with the .nhover
command.
Ex:
it('Should hover and unhover my element', () => {
cy.get('#hoverButton')
.should('have.css', 'background-color', 'rgb(0, 0, 255)') // element isn't hovered and background-color is blue
.nhover()
.should('have.css', 'background-color', 'rgb(255, 0, 0)') // :hover pseudo class active, background-color is red
.nmove({x: 0, y: 0}) // move the mouse cursor to the top left of the window
.should('have.css', 'background-color', 'rgb(0, 0, 255)'); // :hover pseudo isn't active anymore
})
See cypress/integration/spec.js
Those commands use Cypress.automation('remote:debugger:protocol')
calls in background to dispatch MouseEvents
as if user was really interacting with the Page.
cypress open
during running tests) can mess up with assertions because of events race condition.Cypress doesn't currently have the support of this protocol for the Firefox browser.
But since Firefox currently is implementing CDP under Remote, we can fairly assume that it's only a matter of time before this support come into Cypress.
This project is licensed under the terms of the MIT license.
FAQs
Add nhover (NativeHover) command to test runner
The npm package cypress-nhover receives a total of 286 weekly downloads. As such, cypress-nhover popularity was classified as not popular.
We found that cypress-nhover 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.