cypress-network-idle
Advanced tools
Comparing version 1.11.1 to 1.11.2
{ | ||
"name": "cypress-network-idle", | ||
"version": "1.11.1", | ||
"version": "1.11.2", | ||
"description": "A little Cypress.io plugin for waiting for network to be idle before continuing with the test", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -1,2 +0,2 @@ | ||
# cypress-network-idle ![cypress version](https://img.shields.io/badge/cypress-11.2.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.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) | ||
@@ -3,0 +3,0 @@ > A little Cypress.io plugin for waiting for network to be idle before continuing with the test |
@@ -5,2 +5,14 @@ /// <reference types="cypress" /> | ||
// reset all counters after every test | ||
// because Cypress resets all intercepts | ||
// https://github.com/bahmutov/cypress-network-idle/issues/54 | ||
Cypress.on('test:after:run', () => { | ||
const env = Cypress.env() | ||
Cypress._.each(env, (value, key) => { | ||
if (key.startsWith('networkIdleCounters_')) { | ||
delete env[key] | ||
} | ||
}) | ||
}) | ||
function waitForIdle(counters, timeLimitMs, timeout, interval) { | ||
@@ -154,2 +166,3 @@ counters.started = +new Date() | ||
// console.log({ alias, counters: structuredClone(counters) }) | ||
return waitForIdle(counters, timeLimitMs, timeout, interval) | ||
@@ -181,2 +194,4 @@ } | ||
Cypress.log({ name: 'network-idle', message: `prepared for **@${alias}**` }) | ||
const key = `networkIdleCounters_${alias}` | ||
@@ -209,2 +224,3 @@ // check if the intercept has already been set | ||
counters.lastNetworkAt = +new Date() | ||
// console.log('called', method, pattern) | ||
@@ -211,0 +227,0 @@ // seems using event callbacks allows the other stubs to be called |
17194
286