Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions cypress/e2e/support/resize-observer-mock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Mock ResizeObserver to prevent "ResizeObserver loop completed with undelivered notifications" errors
class ResizeObserverMock {
constructor(callback) {
this.callback = callback;
this.observations = new Map();
}

observe(element) {
this.observations.set(element, {});
// Trigger initial callback
this.callback([{ target: element }], this);
}

unobserve(element) {
this.observations.delete(element);
}

disconnect() {
this.observations.clear();
}
}

// Replace the global ResizeObserver with our mock
if (window.ResizeObserver) {
window.ResizeObserver = ResizeObserverMock;
}
26 changes: 12 additions & 14 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import 'cypress-plugin-tab';
import '../e2e/support/resize-observer-mock';

/*
* This is a workaround for the ResizeObserver loop error that occurs in Cypress.
* See https://github.com/cypress-io/cypress/issues/20341
* See https://github.com/cypress-io/cypress/issues/29277
*/
Cypress.on('uncaught:exception', err => {
if (
err.message.includes(
'ResizeObserver loop completed with undelivered notifications'
)
) {
return false;
}
});
// Make the CI fail if console.error in tests
const originalConsoleError = console.error;
console.error = (...args) => {
originalConsoleError.call(console, args);
throw new Error(
JSON.stringify({
message: 'The tests failed due to `console.error` calls',
error: args,
})
);
};