Skip to content

Example waiting for 3rd party JavaScript library to load before testing the page

Notifications You must be signed in to change notification settings

bahmutov/cypress-3rd-party-script-example

Repository files navigation

cypress-3rd-party-script-example deploy cypress-3rd-party-script-example

Example waiting for 3rd party JavaScript library to load before testing the page

The page from public is deployed to https://glebbahmutov.com/cypress-3rd-party-script-example/ and has a Tidio chat widget

Chat widget test

Specs

  • slow-down.js uses cy.intercept to slow down 3rd party JavaScript resource. It waits for the intercept to happen, hoping that 3rd party chat widget is ready after that.
  • wait-for-chat-object.js waits for the window.tidioChatApi property to exist before proceeding. The property is added by the chat code, thus we know it is ready.
  • invoke-open.js shows how the test code can call directly the chat object methods, even if the object was created by the application.
  • spy-on-open.js spies on the application calling tidioChatApi.open() to confirm it was called once without any arguments.
  • events.js subscribes to the chat widget events and confirms the widget delivers the "ready" event.

Blog posts

Videos

Small print

Author: Gleb Bahmutov <[email protected]> © 2021

License: MIT - do anything with the code, but don't blame me if it does not work.

About

Example waiting for 3rd party JavaScript library to load before testing the page

Topics

Resources

Stars

Watchers

Forks