New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cypress-cdp

Package Overview
Dependencies
Maintainers
0
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cypress-cdp - npm Package Compare versions

Comparing version 1.5.5 to 1.6.0

2

package.json
{
"name": "cypress-cdp",
"version": "1.5.5",
"version": "1.6.0",
"description": "A custom Cypress command to wrap the remote debugger protocol low level command",

@@ -5,0 +5,0 @@ "main": "src",

@@ -5,3 +5,3 @@ # cypress-cdp [![ci](https://github.com/bahmutov/cypress-cdp/actions/workflows/ci.yml/badge.svg?branch=main&event=push)](https://github.com/bahmutov/cypress-cdp/actions/workflows/ci.yml) ![cypress version](https://img.shields.io/badge/cypress-13.15.0-brightgreen)

Read the blog posts:
Read my blog posts that show this plugin in action:

@@ -13,2 +13,3 @@ - [Cypress automation](https://glebbahmutov.com/blog/cypress-automation/)

- [Emulate Media In Cypress Tests](https://glebbahmutov.com/blog/cypress-emulate-media/)
- [Testing CSS Print Media Styles](https://glebbahmutov.com/blog/test-print-styles/)

@@ -15,0 +16,0 @@ 🎓 Covered in my course [Cypress Plugins](https://cypress.tips/courses/cypress-plugins) and [Cypress Network Testing Exercises](https://cypress.tips/courses/network-testing).

@@ -54,3 +54,23 @@ /// <reference types="cypress" />

let eventListenerStatus // track most recent failure mode
let eventListenerRun
let maxTimeout
Cypress.Commands.add('hasEventListeners', (selector, options = {}) => {
let retryOpts
if (options.timeout === 0) {
// is a retry
retryOpts = options
} else {
// set up the timer
eventListenerStatus = ''
let runId = Date.now()
eventListenerRun = runId // prevent failing the next test
maxTimeout = options.timeout ?? Cypress.config().defaultCommandTimeout
retryOpts = { ...options, timeout: 0, log: false }
setTimeout(() => {
if (eventListenerRun === runId && eventListenerStatus !== 'Passed') {
throw new Error(eventListenerStatus)
}
}, maxTimeout)
}
const logOptions = {

@@ -65,3 +85,3 @@ name: 'hasEventListeners',

cy.get(selector, { log: false }).should(($el) => {
cy.get(selector, { log: false, timeout: maxTimeout }).should(($el) => {
if ($el.length !== 1) {

@@ -78,3 +98,3 @@ throw new Error(`Need a single element with selector "${selector}`)

},
{ log: false },
{ log: false, timeout: maxTimeout },
)

@@ -97,28 +117,31 @@ .should((v) => {

log: false,
timeout: options.timeout,
},
)
.should((v) => {
if (!v.listeners) {
throw new Error('No listeners')
).then((v) => {
if (!v.listeners) {
eventListenerStatus = 'No listeners'
cy.hasEventListeners(selector, retryOpts)
return
}
if (!v.listeners.length) {
eventListenerStatus = 'Zero listeners'
cy.hasEventListeners(selector, retryOpts)
return
}
if (options.type) {
const filtered = v.listeners.filter((l) => l.type === options.type)
if (!filtered.length) {
eventListenerStatus = `Zero listeners of type "${options.type}"`
cy.hasEventListeners(selector, retryOpts)
return
}
if (!v.listeners.length) {
throw new Error('Zero listeners')
}
if (options.type) {
const filtered = v.listeners.filter((l) => l.type === options.type)
if (!filtered.length) {
throw new Error(`Zero listeners of type "${options.type}"`)
}
eventListenerStatus = 'Passed'
if (options.log !== false) {
logOptions.consoleProps = () => {
return {
result: v.listeners,
}
}
})
.then(({ listeners }) => {
if (options.log !== false) {
logOptions.consoleProps = () => {
return {
result: listeners,
}
}
}
})
}
})
})

@@ -125,0 +148,0 @@ })

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc