Search code examples
javascriptreact-nativejestjsexporeact-native-ui-kitten

Jest encountered an unexpected token UI-Kitten


Jest encountered an unexpected token

This usually means that you are trying to import a file that Jest cannot parse, e.g. it's not plain JavaScript.

SyntaxError: Unexpected token export

      1 | import React from 'react'
    > 2 | import { Button, Layout, Icon } from '@ui-kitten/components'
        | ^

I've added this to my Jest config and seen no change, my app should use babel by default as it was made by expo which installed.

"jest": {
    "preset": "jest-expo",
    "transformIgnorePatterns": [
        "/node_modules/(?!@ui-kitten/components)"
    ]
},

Solution

  • you need to extend the list of transformIgnorePatterns as described in docs.expo.io/versions/latet/guides/testing-with-jest :) – brentvatne Feb 14 at 1:35