Jest and Babel settings for your un-transpiled library

Error : SyntaxError: Unexpected token import for your not transpiled library or may be some other third party library you use in your code base,

I have wasted about 2 days into searching things and stumbled upon a solution so I guess time for me to help my fellow developers,

  1. Do not eject the configuration in your code base.
  2. There was an issue earlier with babel-jest(24.x) for the code that you use in node_modules and are not transpiled and error would be as SyntaxError: Unexpected token import and your un-transpiled library will be displayed,
  3. I did not create jest.config.js or babel.config.js in my project root directory,
  4. In the latest version of create-reat-app you can flag the libraries/files that you wish to transpile

transformIgnorePatterns in package.json

sample package.json after change

now you can runt he test after clearing the cache of jest by running the command as

jest --clearCache

it should ideally solve your problem

anyone faces the problem post here, let me see if i can help