From 86bdb78de7f9ab45c6e17d9ad0266938d9c5b91f Mon Sep 17 00:00:00 2001 From: Ryan Westfall Date: Tue, 4 Aug 2026 05:40:54 -0500 Subject: [PATCH] Mock RevenueCat Capacitor plugin in Jest setup. Package is ESM-only; suites that import AccountContext were crashing Jest with SyntaxError before any tests ran. --- llm-fe/src/setupTests.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/llm-fe/src/setupTests.ts b/llm-fe/src/setupTests.ts index 8f2609b..c67cc79 100644 --- a/llm-fe/src/setupTests.ts +++ b/llm-fe/src/setupTests.ts @@ -3,3 +3,16 @@ // expect(element).toHaveTextContent(/react/i) // learn more: https://github.com/testing-library/jest-dom import '@testing-library/jest-dom'; + +// Capacitor plugin ships ESM; Jest cannot parse it when AccountContext +// (or pages that import it) pull in utils/revenueCat. Stub globally. +jest.mock('@revenuecat/purchases-capacitor', () => ({ + Purchases: { + configure: jest.fn(() => Promise.resolve()), + logIn: jest.fn(() => Promise.resolve({ customerInfo: {} })), + logOut: jest.fn(() => Promise.resolve({ customerInfo: {} })), + getOfferings: jest.fn(() => Promise.resolve({ current: null, all: {} })), + purchasePackage: jest.fn(() => Promise.resolve({ customerInfo: {} })), + restorePurchases: jest.fn(() => Promise.resolve({ customerInfo: {} })), + }, +}));