Files
lucia-frontend/cypress/support/uncaughtExceptionPolicy.js

27 lines
1.0 KiB
JavaScript

// The Lucia project.
// Copyright 2026-2026 DSP, inc. All rights reserved.
// Authors:
// imacat.yang@dsp.im (imacat), 2026/03/08
/**
* Returns whether an uncaught exception should be ignored in Cypress.
* @param {unknown} error - The thrown uncaught exception.
* @returns {boolean} True when the exception is known-benign and safe to ignore.
*/
export function shouldIgnoreUncaughtException(error) {
const message = error instanceof Error ? error.message : String(error);
const ignorePatterns = [
/ResizeObserver loop limit exceeded/i,
/ResizeObserver loop completed with undelivered notifications/i,
];
return ignorePatterns.some((pattern) => pattern.test(message));
}
/**
* Converts ignore policy into Cypress uncaught-exception callback return value.
* @param {unknown} error - The thrown uncaught exception.
* @returns {false|undefined} False to ignore, undefined to let Cypress fail the test.
*/
export function getCypressUncaughtExceptionDecision(error) {
return shouldIgnoreUncaughtException(error) ? false : undefined;
}