I've a problem to setup Jest with Expo and Typescript for React Native.Jest shows me this: TypeError: Jest: a transform must export a `process` function.
My test
import React from 'react';import renderer from 'react-test-renderer';import { SocialIcon } from '../src/components';describe('<SocialIcon />', () => { it('has 1 child', () => { const tree = renderer.create(<SocialIcon />).toJSON(); expect(tree).toMatchSnapshot(); });});
My package.json:
"jest": "^27.0.4","jest-expo": "^41.0.0","prettier": "^2.2.1","react-test-renderer": "^17.0.2","ts-jest": "^27.0.3","jest": {"preset": "jest-expo","transformIgnorePatterns": ["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|@sentry/.*)" ],"transform": {"^.+\\.tsx?$": "ts-jest","^.+\\.(js|jsx)$": "babel-jest" },"moduleFileExtensions": ["ts","tsx","js","jsx","json" ],}
My jest.config.js:
module.exports = { preset: 'ts-jest', testEnvironment: 'node', coverageThreshold: { global: { branches: 75, functions: 80, lines: 90, statements: 90, }, }, coverageReporters: ['json', 'lcov', 'text', 'clover'], transform: {'^.+\\.(ts|tsx)?$': 'ts-jest','^.+\\.(js|jsx)$': 'babel-jest', },};
And my babel.config.js
module.exports = function (api) { api.cache(true); return { presets: ['babel-preset-expo'], };};
I've already tried all of stackoverflow and forum topics. So i don't know what i can do now. If i remove the babel-jest in the jest.config i got the following error:SyntaxError: Cannot use import statement outside a module
If anyone has a solution i will take it. I've already cleared the cache with jest --clearCache