Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-native jest test giving unexpected token

Getting an unexpected token from the component class. Looking for advice on how I can proceed.

The failure:

  ● Test suite failed to run

C:/../react-native/jest/mockComponent.js: Unexpected token (20:23)

  Jest encountered an unexpected token
  This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
  By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
  Here's what you can do:
   • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
   • If you need a custom transformation specify a "transform" option in your config.
   • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
  You'll find more details and examples of these config options in the docs:
  https://jestjs.io/docs/en/configuration.html
  Details:
    18 |
    19 |   const Component = class extends SuperClass {
  > 20 |     static displayName = 'Component';
       |                        ^
    21 |
    22 |     render() {
    23 |       const name =
like image 760
Chris Avatar asked Nov 28 '18 16:11

Chris


1 Answers

This worked for me https://github.com/expo/expo/issues/2595#issuecomment-440966998

I think the problem was having jest and jest-expo installed

like image 193
DPA Avatar answered Oct 23 '22 20:10

DPA