All Projects → jtassin → Pending Xhr Puppeteer

jtassin / Pending Xhr Puppeteer

Licence: mit
Small tool to wait that all xhr are finished in puppeteer

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Pending Xhr Puppeteer

phantom-lord
Handy API for Headless Chromium
Stars: ✭ 24 (-89.43%)
Mutual labels:  e2e-tests, puppeteer
Softest
Recording Browser Interactions And Generating Test Scripts.
Stars: ✭ 208 (-8.37%)
Mutual labels:  e2e-tests, puppeteer
Recorder
A browser extension that generates Cypress, Playwright and Puppeteer test scripts from your interactions 🖱 ⌨
Stars: ✭ 277 (+22.03%)
Mutual labels:  e2e, puppeteer
jest-retry
Jest retry pattern for flaky E2E tests
Stars: ✭ 36 (-84.14%)
Mutual labels:  e2e-tests, e2e
Tib
Easy e2e browser testing in Node
Stars: ✭ 64 (-71.81%)
Mutual labels:  e2e, puppeteer
cypress-page-object
Represent the screens of your website as a series of objects in your Cypress test suite
Stars: ✭ 23 (-89.87%)
Mutual labels:  e2e-tests, e2e
curso-javascript-testes
Código-fonte do curso "Aprenda a testar Aplicações Javascript"
Stars: ✭ 60 (-73.57%)
Mutual labels:  e2e-tests, e2e
playwright-demos
playwright for scrapping and UI testing / automate testing workflows
Stars: ✭ 65 (-71.37%)
Mutual labels:  e2e, puppeteer
babel-plugin-remove-test-ids
🐠 Babel plugin to strip `data-test-id` HTML attributes
Stars: ✭ 40 (-82.38%)
Mutual labels:  e2e-tests, e2e
cypress-xhr-responses-recording
No description or website provided.
Stars: ✭ 19 (-91.63%)
Mutual labels:  xhr, e2e
Root Cause
🔍 Root Cause is a tool for troubleshooting Puppeteer and Playwright tests. 🔎
Stars: ✭ 205 (-9.69%)
Mutual labels:  e2e-tests, puppeteer
Dappeteer
🏌🏼‍E2E testing for dApps using Puppeteer + MetaMask
Stars: ✭ 117 (-48.46%)
Mutual labels:  e2e, puppeteer
puppeteer-jest-starter
A starter-kit quipped with the minimal requirements for Puppeteer + Jest, making E2E testing a breeze.
Stars: ✭ 17 (-92.51%)
Mutual labels:  e2e-tests, puppeteer
jest-puppeteer-istanbul
Collect code coverage information from end-to-end jest puppeteer tests
Stars: ✭ 26 (-88.55%)
Mutual labels:  e2e, puppeteer
IridiumApplicationTesting
A&G Web Application Testing Suite
Stars: ✭ 19 (-91.63%)
Mutual labels:  e2e-tests, e2e
ionic-workflow-guide
Create a full and powerful worflow with Ionic (Unit Testing, Environment variables, Automatic documentation, Production App Server, Automatic deployment)
Stars: ✭ 46 (-79.74%)
Mutual labels:  e2e-tests, e2e
playwright-ci
☁️ Set up Playwright in CI
Stars: ✭ 27 (-88.11%)
Mutual labels:  e2e-tests, e2e
softest
Recording Browser Interactions And Generating Test Scripts.
Stars: ✭ 225 (-0.88%)
Mutual labels:  e2e-tests, puppeteer
expo-detox-typescript-example
Sample Expo app with e2e tests using detox, jest and typescript
Stars: ✭ 81 (-64.32%)
Mutual labels:  e2e-tests, e2e
Sakuli
Sakuli is an end-2-end testing and monitoring tool for web sites and common UIs with multiple monitoring integrations
Stars: ✭ 115 (-49.34%)
Mutual labels:  e2e-tests, e2e

Pending XHR Puppeteer

npm version Build Status

| Introduction | Installation | Usage | Contribute |

Introduction

Pending XHR Puppeteer is a tool that detect when there is xhr requests not yet finished. You can use it to have a xhr requests count or to wait for all xhr requests to be finished.

Installation

To install with yarn :

yarn add pending-xhr-puppeteer -D

To install with npm :

npm install pending-xhr-puppeteer --save-dev

Usage

wait for all xhr requests to be finished

const puppeteer = require('puppeteer');
const { PendingXHR } = require('pending-xhr-puppeteer');

const browser = await puppeteer.launch({
  headless: true,
  args,
});

const page = await browser.newPage();
const pendingXHR = new PendingXHR(page);
await page.goto(`http://page-with-xhr`);
// Here all xhr requests are not finished
await pendingXHR.waitForAllXhrFinished();
// Here all xhr requests are finished

Get the number of pending xhr

const puppeteer = require('puppeteer');
const { PendingXHR } = require('pending-xhr-puppeteer');

const browser = await puppeteer.launch({
  headless: true,
  args,
});

const page = await browser.newPage();
const pendingXHR = new PendingXHR(page);
await page.goto(`http://page-with-xhr`);
console.log(pendingXHR.pendingXhrCount());
// Display the number of xhr pending

Usage with Promise.race

If you need to wait xhrs but not longer than a specific time, You can race pending-xhr-puppeteer and setTimeout in a Promise.race.

const puppeteer = require('puppeteer');
const { PendingXHR } = require('pending-xhr-puppeteer');

const browser = await puppeteer.launch({
  headless: true,
  args,
});

const page = await browser.newPage();
const pendingXHR = new PendingXHR(page);
await page.goto(`http://page-with-xhr`);
// We will wait max 1 seconde for xhrs
await Promise.race([
  pendingXHR.waitForAllXhrFinished(),
  new Promise(resolve => {
    setTimeout(resolve, 1000);
  }),
]);
console.log(pendingXHR.pendingXhrCount());
// May or may not have pending xhrs

Wait for all xhr triggered by all the events of the page

You can use this lib to wait for xhr triggered by any event from the UI (click, typing, ...).

Exemple :

const pendingXHR = new PendingXHR(page);
await page.goto(`http://page-with-xhr`);
await page.click('.my-selector'); // This action will trigger some xhr
// Here all xhr requests triggered by the click are not finished
await pendingXHR.waitForAllXhrFinished();
// Here all xhr requests triggered by the click are finished
// You can then perform an other xhr producer event
await page.click('.my-selector2'); // This action will trigger some xhr
// You can rewait them
await pendingXHR.waitForAllXhrFinished();

This mode is usefull to test SPA, you d'ont have to recreate a new instance at each time. The request listeners will be deleted when you leave the page.

Wait for all xhr triggered by an event of the page

with waitOnceForAllXhrFinished you can wait until all the xhr are finished and them remove the listeners. This is usefull when waitForAllXhrFinished has a leaking behaviour for you.

Exemple :

const pendingXHR = new PendingXHR(page);
await page.goto(`http://page-with-xhr`);
await page.click('.my-selector'); // This action will trigger some xhr
// Here all xhr requests triggered by the click are not finished
await pendingXHR.waitOnceForAllXhrFinished();
// Here all xhr requests triggered by the click are finished
// All pendingXHR listeners are remove here too

Contribute

git clone https://github.com/jtassin/pending-xhr-puppeteer.git
cd pending-xhr-puppeteer
yarn
yarn test

Merge requests and issues are welcome.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].