diff --git a/__mocks__/moti.js b/__mocks__/moti.js new file mode 100644 index 00000000000..3c4a1045b64 --- /dev/null +++ b/__mocks__/moti.js @@ -0,0 +1,24 @@ +// Mock for moti to reduce memory usage in tests +const React = require("react") +const { View } = require("react-native") + +module.exports = { + __esModule: true, + MotiView: View, + View: View, + AnimatePresence: ({ children }) => React.createElement(React.Fragment, null, children), + motify: (Component) => () => Component, + useDynamicAnimation: () => ({ + current: { + height: 0, + }, + start: jest.fn(), + stop: jest.fn(), + animateTo: jest.fn(), + animateToEnd: jest.fn(), + animateToStart: jest.fn(), + animateToValue: jest.fn(), + animateToEndValue: jest.fn(), + animateToStartValue: jest.fn(), + }), +} diff --git a/__mocks__/moti/interactions.js b/__mocks__/moti/interactions.js new file mode 100644 index 00000000000..1bb6caa9319 --- /dev/null +++ b/__mocks__/moti/interactions.js @@ -0,0 +1,7 @@ +// Mock for moti/interactions to reduce memory usage in tests +const { Pressable } = require("react-native") + +module.exports = { + __esModule: true, + MotiPressable: Pressable, +} diff --git a/alias.js b/alias.js index e9f0e03f5ec..dfd7475c68a 100644 --- a/alias.js +++ b/alias.js @@ -18,6 +18,10 @@ const jestModuleNameMap = list.reduce((acc, name) => { }, {}) jestModuleNameMap["^images/(.*)"] = "/images/$1" +// Mock moti to reduce memory usage - catches both top-level and nested node_modules +jestModuleNameMap["^moti$"] = "/__mocks__/moti.js" +jestModuleNameMap["^moti/(.*)$"] = "/__mocks__/moti/$1.js" + module.exports = { babelModuleResolverAlias, jestModuleNameMap,