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
- 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.
- Slow Down And Wait For 3rd Party JavaScript To Load
- Spy On The Application Calling 3rd Party Library Code
- Cypress Dashboard, Reusing GitHub Workflows, Flake Detection, And Test Retries
Author: Gleb Bahmutov <gleb.bahmutov@gmail.com> © 2021
License: MIT - do anything with the code, but don't blame me if it does not work.