Skip to content

Commit

Permalink
Cleaning up jest setup/mocking
Browse files Browse the repository at this point in the history
  • Loading branch information
7emansell committed Dec 20, 2024
1 parent e130686 commit 994902d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion app/src/components/featuredItem/campaignHero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ const CampaignHero = ({ featuredItemData }) => {
);

const handleError = (e: React.SyntheticEvent<HTMLImageElement, Event>) => {
console.log("Error loading campaign hero:", e);
if ((window as any).newrelic) {
(window as any).newrelic.log("Error loading campaign hero", {
level: "warn",
});
}
setData(defaultFeaturedItemResponse);
};

Expand Down
1 change: 0 additions & 1 deletion app/src/utils/fetchApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ export const fetchApi = async (
),
]);
};
logger.error("test error from fetch API");

try {
const response = (await fetchWithTimeout(apiUrl, {
Expand Down
7 changes: 7 additions & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,10 @@ global.ResizeObserver = jest.fn().mockImplementation(() => ({
unobserve: jest.fn(),
disconnect: jest.fn(),
}));

(global as any).setImmediate = Object.assign(
(fn: (...args: any[]) => void, ...args: any[]) => setTimeout(fn, 0, ...args),
{
__promisify__: () => Promise.resolve(), // Add the __promisify__ property
}
);
1 change: 0 additions & 1 deletion jestAPI.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ const config = {
"__tests__/data/*",
"__tests__/pages/*",
"__tests__/__mocks__/*",
"__tests__/api/featuredItem",
"app/*",
],
moduleNameMapper: {
Expand Down

0 comments on commit 994902d

Please sign in to comment.