diff --git a/packages/@lwc/integration-karma/helpers/test-utils.js b/packages/@lwc/integration-karma/helpers/test-utils.js index 5b72251959..b87e7a29ab 100644 --- a/packages/@lwc/integration-karma/helpers/test-utils.js +++ b/packages/@lwc/integration-karma/helpers/test-utils.js @@ -596,18 +596,18 @@ window.TestUtils = (function (lwc, jasmine, beforeAll) { // Utility to handle unhandled rejections or errors without allowing Jasmine to handle them first. // Captures both onunhandledrejection and onerror events, since you might want both depending on // native vs synthetic lifecycle timing differences. - function catchUnhandledRejectionOrError(onUnhandledRejection) { + function catchUnhandledRejectionsAndErrors(onUnhandledRejectionOrError) { let originalOnError; const onError = (e) => { e.preventDefault(); // Avoids logging to the console - onUnhandledRejection(e); + onUnhandledRejectionOrError(e); }; const onRejection = (e) => { // Avoids logging the error to the console, except in Firefox sadly https://bugzilla.mozilla.org/1642147 e.preventDefault(); - onUnhandledRejection(e.reason); + onUnhandledRejectionOrError(e.reason); }; beforeEach(() => { @@ -666,7 +666,7 @@ window.TestUtils = (function (lwc, jasmine, beforeAll) { IS_SYNTHETIC_SHADOW_LOADED, expectConsoleCalls, expectConsoleCallsDev, - catchUnhandledRejectionOrError, + catchUnhandledRejectionsAndErrors, ...apiFeatures, }; })(LWC, jasmine, beforeAll); diff --git a/packages/@lwc/integration-karma/test/component/LightningElement.errorCallback/index.spec.js b/packages/@lwc/integration-karma/test/component/LightningElement.errorCallback/index.spec.js index c44703679f..d8f6df35f6 100644 --- a/packages/@lwc/integration-karma/test/component/LightningElement.errorCallback/index.spec.js +++ b/packages/@lwc/integration-karma/test/component/LightningElement.errorCallback/index.spec.js @@ -1,5 +1,5 @@ import { createElement } from 'lwc'; -import { catchUnhandledRejectionOrError } from 'test-utils'; +import { catchUnhandledRejectionsAndErrors } from 'test-utils'; import XBoundaryChildConstructorThrow from 'x/boundaryChildConstructorThrow'; import XBoundaryChildConnectedThrow from 'x/boundaryChildConnectedThrow'; import XBoundaryChildRenderThrow from 'x/boundaryChildRenderThrow'; @@ -296,7 +296,7 @@ describe('errorCallback throws after value mutation', () => { // Depending on whether native custom elements lifecycle is enabled or not, this may be an unhandled error or an // unhandled rejection. This utility captures both. - catchUnhandledRejectionOrError((error) => { + catchUnhandledRejectionsAndErrors((error) => { caughtError = error; }); diff --git a/packages/@lwc/integration-karma/test/rendering/callback-invocation-order/index.spec.js b/packages/@lwc/integration-karma/test/rendering/callback-invocation-order/index.spec.js index 1a07b02d1c..a58ba7d429 100644 --- a/packages/@lwc/integration-karma/test/rendering/callback-invocation-order/index.spec.js +++ b/packages/@lwc/integration-karma/test/rendering/callback-invocation-order/index.spec.js @@ -1,5 +1,5 @@ import { createElement } from 'lwc'; -import { catchUnhandledRejectionOrError } from 'test-utils'; +import { catchUnhandledRejectionsAndErrors } from 'test-utils'; import ShadowParent from 'x/shadowParent'; import ShadowLightParent from 'x/shadowLightParent'; import LightParent from 'x/lightParent'; @@ -305,7 +305,7 @@ describe('regression test (#3827)', () => { // TODO [#4451]: synthetic shadow throws unhandled rejection errors // These handlers capture errors thrown in synthetic shadow mode after the rerendering happens. - catchUnhandledRejectionOrError((error) => { + catchUnhandledRejectionsAndErrors((error) => { caughtErrors.push(error); });