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

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 <gleb.bahmutov@gmail.com> © 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


Languages

Language:JavaScript 86.5%Language:HTML 13.5%