I am trying to use typescript and jest with expo (jest will be in js or ts-jest), and no matter what I do I keep getting this error when i try running jest:
tsjest\node_modules.pnpm@react-native+polyfills@2.0.0\node_modules@react-native\polyfills\error-guard.js:14
type ErrorHandler = (error: mixed, isFatal: Boolean) => void;
^^^^^^^^^^^^
SyntaxError: Unexpected identifier 'ErrorHandler'
at Runtime.createScriptFromCode (node_modules/.pnpm/jest-runtime@29.5.0/node_modules/jest-runtime/build/index.js:1495:14)
I tried every way i found online and even tried my best with chatgpt and I couldnβt fix it, I looked at the docs for both jest, rn, and expo and couldnβt find a solution for this error. I tried ignoring it in the jest.config.js and that also didnβt work
for my jest.config.js and babel.config.js they changed so many times in so many ways but i will paste what i currently have:
babel.config.js
β File: .\babel.config.js
1 β module. Exports = function(api) {
2 β api.cache(true);
3 β return {
4 β presets: [βbabel-preset-expoβ],
5 β };
6 β };
jest.config.js
β File: .\jest.config.js
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
1 β module.exports = {
2 β preset: βjest-expoβ,
3 β transformIgnorePatterns: [
4 β βnode_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-native-community|expo(nent)?|@expo(
β nent)?/.|react-navigation|@react-navigation/.|@unimodules/.|unimodules|sentry-expo|native-base|(@react-nativ
β e/polyfills|@react-native/polyfills/.))β
5 β ],
6 β setupFilesAfterEnv: [β@testing-library/jest-native/extend-expectβ],
7 β };