Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cypress-network-idle

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cypress-network-idle - npm Package Compare versions

Comparing version 1.11.2 to 1.12.0

4

package.json
{
"name": "cypress-network-idle",
"version": "1.11.2",
"version": "1.12.0",
"description": "A little Cypress.io plugin for waiting for network to be idle before continuing with the test",

@@ -34,3 +34,3 @@ "main": "src/index.js",

"devDependencies": {
"cypress": "12.1.0",
"cypress": "12.5.0",
"micro": "^9.3.4",

@@ -37,0 +37,0 @@ "micro-dev": "^3.0.0",

@@ -1,2 +0,2 @@

# cypress-network-idle ![cypress version](https://img.shields.io/badge/cypress-12.1.0-brightgreen) [![renovate-app badge][renovate-badge]][renovate-app] [![ci](https://github.com/bahmutov/cypress-network-idle/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/bahmutov/cypress-network-idle/actions/workflows/ci.yml)
# cypress-network-idle ![cypress version](https://img.shields.io/badge/cypress-12.3.0-brightgreen) [![renovate-app badge][renovate-badge]][renovate-app] [![ci](https://github.com/bahmutov/cypress-network-idle/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/bahmutov/cypress-network-idle/actions/workflows/ci.yml)

@@ -10,2 +10,6 @@ > A little Cypress.io plugin for waiting for network to be idle before continuing with the test

## Study
Covered in my course 🎓 [Cypress Network Testing](https://cypress.tips/courses/network-testing)
## Install

@@ -110,2 +114,19 @@

### fail on 5xx
By default, the network calls might fail and the test happily continues. You can make the idle spy fail if any of the matching network calls return 4xx or 5xx errors. These classes of error status code have their own flag to enable.
```js
// fail the test if any of the matching calls
// returns a 5xx status code
cy.waitForNetworkIdlePrepare({
method: '*',
alias: 'all',
pattern: '**',
failOn5xx: true,
})
```
![The test fails when one of the calls receives 500 from the server](./images/5xx.png)
## Multiple registrations

@@ -112,0 +133,0 @@

@@ -39,2 +39,6 @@ // load type definitions that come with Cypress module

/**
* Starts spying on the matching network calls
* @see https://github.com/bahmutov/cypress-network-idle#readme
*/
waitForNetworkIdlePrepare(

@@ -66,3 +70,8 @@ options: WaitForNetworkIdlePrepareOptions,

log?: boolean
/**
* Fail the test if any of the matching network calls
* returns 5xx status code
*/
failOn5xx?: boolean
}
}

@@ -179,3 +179,9 @@ /// <reference types="cypress" />

function waitForNetworkIdlePrepare({ method, pattern, alias, log } = {}) {
function waitForNetworkIdlePrepare({
method,
pattern,
alias,
log,
failOn5xx,
} = {}) {
if (!alias) {

@@ -193,3 +199,7 @@ throw new Error('cypress-network-idle: alias is required')

Cypress.log({ name: 'network-idle', message: `prepared for **@${alias}**` })
let message = `prepared for **@${alias}**`
if (failOn5xx) {
message += ' (will fail on **5xx**)'
}
Cypress.log({ name: 'network-idle', message })

@@ -232,2 +242,7 @@ const key = `networkIdleCounters_${alias}`

// console.log(res.body)
if (failOn5xx && res.statusCode >= 500) {
throw new Error(
`Network call ${req.method} ${req.url} failed with ${res.statusCode}`,
)
}
})

@@ -234,0 +249,0 @@ }).as(alias)

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