Jest遇到意外的令牌UI小猫

时间:2020-02-14 01:26:00

标签: javascript react-native jestjs expo react-native-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'
        | ^

我已将其添加到我的Jest配置中,未发现任何变化,默认情况下,我的应用应使用babel,因为它是由安装的expo制作的。

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

1 个答案:

答案 0 :(得分:0)

您需要按照docs.expo.io/versions/latet/guides/testing-with-jest中的描述来扩展transformIgnorePatterns的列表:) – brentvatne 2月14日下午1:35