Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6214

Tests fail to run with Jest and React Native

$
0
0

Using React Native with Jest and TypeScript, when trying to run the tests I get:

Test suite failed to run    [BABEL] unknown: Preset /* your preset */ requires a filename to be set when babel is called directly,    babel.transform(code, { filename: 'file.ts', presets: [/* your preset */] });    See https://babeljs.io/docs/en/options#filename for more information.

Any idea what can cause this?

This is my jest section on package.json:

"jest": {"preset": "react-native","roots": ["<rootDir>/__tests__"    ],"setupFiles": ["<rootDir>/scripts/jest/setup.js","<rootDir>/node_modules/appcenter/test/AppCenterMock.js","<rootDir>/node_modules/appcenter-analytics/test/AppCenterAnalyticsMock.js","<rootDir>/node_modules/appcenter-crashes/test/AppCenterCrashesMock.js","<rootDir>/node_modules/appcenter-push/test/AppCenterPushMock.js","<rootDir>/node_modules/react-native-localization.js","./config/jest/mock.fetch.js","./config/jest/react-native-localization.js"    ],"moduleFileExtensions": ["ts","tsx","js"    ],"transform": {"^.+\\.(js)$": "<rootDir>/node_modules/babel-jest","\\.(ts|tsx)$": "<rootDir>/node_modules/ts-jest/preprocessor.js"    },"collectCoverage": true,"coverageDirectory": "coverage","coverageReporters": ["text-summary","html"    ],"testPathIgnorePatterns": ["\\.snap$","<rootDir>/node_modules/","<rootDir>/lib/"    ],"collectCoverageFrom": ["**/*.{js,jsx}","artifacts/**/*.js","!artifacts/**/*.spec.js","!artifacts/**/*.index.js","!<rootDir>/node_modules/"    ]  },

and this is my babel.config.js file:

module.exports = {  presets: ['module:metro-react-native-babel-preset'  ],  plugins: ['babel-plugin-transform-typescript-metadata',    ['@babel/plugin-proposal-decorators', { legacy: true }]  ],};

Viewing all articles
Browse latest Browse all 6214

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>