Skip to content

Commit

Permalink
refactor: improve func name
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson committed Aug 9, 2024
1 parent c678a87 commit 286c696
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions packages/@lwc/integration-karma/helpers/test-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down Expand Up @@ -666,7 +666,7 @@ window.TestUtils = (function (lwc, jasmine, beforeAll) {
IS_SYNTHETIC_SHADOW_LOADED,
expectConsoleCalls,
expectConsoleCallsDev,
catchUnhandledRejectionOrError,
catchUnhandledRejectionsAndErrors,
...apiFeatures,
};
})(LWC, jasmine, beforeAll);
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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;
});

Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
});

Expand Down

0 comments on commit 286c696

Please sign in to comment.