Skip to content
This repository was archived by the owner on Apr 18, 2024. It is now read-only.
Next Next commit
Fail E2E test if Image is not loaded
  • Loading branch information
hlomzik committed Feb 23, 2024
commit 3f86dacf95b4a82840e469cee2084c8802ff9375
4 changes: 3 additions & 1 deletion e2e/tests/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,16 @@ const createAddEventListenerScript = (eventName, callback) => {
* Wait for the main Image object to be loaded
*/
const waitForImage = () => {
return new Promise((resolve) => {
return new Promise((resolve, reject) => {
const img = document.querySelector('[alt=LS]');

if (!img || img.complete) return resolve();
// this should be rewritten to isReady when it is ready
img.onload = () => {
setTimeout(resolve, 100);
};
// if image is not loaded in 10 seconds, reject
setTimeout(reject, 10000);
});
};

Expand Down