react-native-root-toast icon indicating copy to clipboard operation
react-native-root-toast copied to clipboard

Error on running jest tests

Open zeljkoX opened this issue 8 years ago • 7 comments

 /Users/user/dir/node_modules/static-container/StaticContainer.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import React, { Component, Children, PropTypes } from 'react';
                                                                                             ^^^^^^
    SyntaxError: Unexpected token import

      at transformAndBuildScript (node_modules/jest-runtime/build/transform.js:320:12)
      at Object.<anonymous> (node_modules/react-native-root-siblings/lib/AppRegistryInjection.js:3:22)
      at Object.<anonymous> (node_modules/react-native-root-siblings/lib/SiblingsManager.js:3:27)

I find this error to be invoked by using package react-native-root-siblings which in new release is using static-container package which is not transformed with babel.

Quick fix is to install older version of package npm install [email protected]

zeljkoX avatar Mar 15 '17 14:03 zeljkoX

Thanks!

enstulen avatar Apr 10 '17 13:04 enstulen

you could use this as a work around too

"jest": {
    "preset": "react-native",
    "transformIgnorePatterns": [
      "node_modules/?!(react-native-root-siblings)"
    ]
}

stonexer avatar May 05 '17 06:05 stonexer

ignore react-native-root-siblings didn't work for me, but ignore static-container works.

"jest": {
    "preset": "react-native",
    "transformIgnorePatterns": [
      "node_modules/(?!static-container)"
    ]
  },

dongyuwei avatar Nov 22 '17 08:11 dongyuwei

same as @dongyuwei

Tamiyadd avatar Nov 27 '17 11:11 Tamiyadd

you could use this as a work around too

"jest": {
    "preset": "react-native",
    "transformIgnorePatterns": [
      "node_modules/?!(react-native-root-siblings)"
    ]
}

Not working, please help me how can test the component. If I remove this then all works fine.

chetanparmar95 avatar Sep 10 '19 06:09 chetanparmar95

ignore react-native-root-siblings didn't work for me, but ignore static-container works.

"jest": {
    "preset": "react-native",
    "transformIgnorePatterns": [
      "node_modules/(?!static-container)"
    ]
  },

This is a good workaround but is only necessary because the authors of this library don't pre-compile their files. This is sadly one for the static-container maintainers so this should probs be closed with some docs added to the README.

neverstew avatar Jan 29 '20 20:01 neverstew

How about this

"transformIgnorePatterns": [
      "/node_modules/(?!react-native)/.+"
 ],

pavermakov avatar Mar 19 '20 11:03 pavermakov