cypress-network-idle
Cypress
cypress-network-idle | Cypress | |
---|---|---|
1 | 174 | |
60 | 46,167 | |
- | 0.4% | |
8.5 | 9.8 | |
9 days ago | 2 days ago | |
JavaScript | JavaScript | |
- | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
cypress-network-idle
-
Hasura E2E tests chronicles, February 2023
/** * Wait for a bunch of requests to be settled before proceeding with the test. * * Alternatively, https://github.com/bahmutov/cypress-network-idle could be used * * This is a workaround for "element is 'detached' from the DOM" Cypress' error (see the issue * linked below). Since the UI gets re-rendered because of the requests, this utility ensures that * all the requests parallelly made by the UI are settled before proceeding with the test. Hence, it * ensure the UI won't re-render during the next interaction. * * What are the requests that must be awaited? By looking at the Cypress Test Runner, they are the * following, made parallelly or in a rapid series. * 1. export_metadata * 2. export_metadata * 3. export_metadata * 4. test_webhook_transform * 5. test_webhook_transform * 6. test_webhook_transform * 7. test_webhook_transform * At the moment of writing, I'm not sure the number of requests are fixed or not. If they are fixed, * using the cy.intercept `times` options would result in a more expressive and less convoluted code. * * To give you an overall idea, this is a timeline of the requests * * all requests start all requests end * | | | | * |--π¦π΄--1--2--3--4--5--6--7----------------------------1--2--3--4--5--6-7--π¦π’--| * * * ATTENTION: Despite the defensive approach and the flakiness-removal purpose, this function could * introduced even more flakiness because of its empiric approach. In case of failures, it must be * carefully evaluated when/if keeping it or thinking about a better approach. * In general, this solution does not scale, it should not be spread among the tests. * * @see https://github.com/cypress-io/cypress/issues/7306 * @see https://glebbahmutov.com/blog/detached/ * @see https://github.com/bahmutov/cypress-network-idle */ import 'cypress-wait-until'; export function waitForPostCreationRequests() { let waitCompleted = false; cy.log('*--- All requests must be settled*'); const pendingRequests = new Map(); cy.intercept('POST', 'http://localhost:8080/v1/metadata', req => { if (waitCompleted) return; Cypress.log({ message: '*--- Request pending*' }); pendingRequests.set(req, true); req.continue(() => { Cypress.log({ message: '*--- Request settled*' }); pendingRequests.delete(req); }); }); Cypress.log({ message: '*--- Waiting for the first request to start*' }); // Check if at least one request has been caught. This check must protect from the following case // // check requests start test failure, the requests got the UI re-rendered // | | | // |--π¦π΄----β οΈ---π¦π’-------1-2-3-4-5-6-7-1----------π₯ // // where checking that "there are no pending requests" falls in the false positive case where // there are no pending requests because no one started at all. // // The check runs every millisecond to be 100% sure that no request can escape (ex. because of a // super fast server). A false-negative case represented here // // requests start requests end check check test failure, no first request caught // | | | | | | | // |--π¦π΄--1-2-3-4-5-6-7-1-2-3-4-5-6-7--β οΈ------------------β οΈ------------------π₯ cy.waitUntil(() => pendingRequests.size > 0, { timeout: 5000, // 5 seconds is the default Cypress wait for a request to start interval: 1, errorMsg: 'No first request caught', }); Cypress.log({ message: '*--- Waiting for all the requests to start*' }); // Let pass some time to collect all the requests. Otherwise, it could detect that the first // request complete and go on with the test, even if another one will be performed in a while. // // This fixed wait protects from the following timeline // // 1st request start first request end other requests start test failure, the requests got the UI re-rendered // | | | | // |--π¦π΄---1---------------------1----π¦π’----------------2-3-4-5-6-7-1----------π₯ // // Obviously, it is an empiric waiting, that also slows down the test. cy.wait(500); Cypress.log({ message: '*--- Waiting for all the requests to be settled*' }); cy.waitUntil(() => pendingRequests.size === 0, { timeout: 30000, // 30 seconds is the default Cypress wait for the request to complete errorMsg: 'Some requests are not settled yet', }).then(() => { waitCompleted = true; }); }
Cypress
-
Simulating Internet Outage and Recovery using Cypress
In this blog post, we'll explore a Cypress test that replicates this scenario, utilizing the powerful intercept command to manipulate network requests and responses.
-
Testing Defer Blocks in Angular with Cypress
Recently I came across this issue while triaging some issues at Cypress. (Shout out to MattiaMalandrone for creating an issue with clear instructions for how to reproduce). After quickly replicating the issue I sought after a solution which ultimately inspired me to write this article.
- Cypress changed older versions to block third-party plugins (ignoring lockfiles)
- Cypress can't open Tesla.com website
-
What is Playwright?
While similar to Puppeteer, Cypress, and Selenium, there are some differences. Letβs find out what they are.
- Episode 23/37: ISR in Angular, Cypress & Playwright
-
/Does Cypress Component Testing Work With Libraries
This questions was asked a while ago and pretty much went unanswered: https://github.com/cypress-io/cypress/issues/23677. If it doesn't work with libraries yet I will stop battling with it for now. If it doesn't work, what are you using to test libraries?
- Finally promising Web Testing solution
-
Episode 23/27: NgRx 16.1 & Signal Store, Jest, Cypress, Nx
Cypress Release Notes
- Trouble/Weirdness with accessing aliased values in `this` context
What are some alternatives?
Playwright - Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
Detox - Gray box end-to-end testing and automation framework for mobile apps
jest - Delightful JavaScript Testing.
kafka-test-helper - Utility library that simplify testing of Node.js components that interacts with Kafka broker.
supertest - π· Super-agent driven library for testing node.js HTTP servers using a fluent API. Maintained for @forwardemail, @ladjs, @spamscanner, @breejs, @cabinjs, and @lassjs.
Sentry - Developer-first error tracking and performance monitoring
WebdriverIO - Next-gen browser and mobile automation test framework for Node.js
TestCafe - A Node.js tool to automate end-to-end web testing.
jasmine - Simple JavaScript testing framework for browsers and node.js
pactum - REST API Testing Tool for all levels in a Test Pyramid
Tailwind CSS - A utility-first CSS framework for rapid UI development.
puppeteer - Node.js API for Chrome