指定 babel-jest 成為 jest 的 transformer
whck6
當專案中有 jsx
的檔案時,會得到下列的錯誤訊息:
Jest encountered an unexpected token
Details:
import { Pressable } from 'react-native'
^^^^^^
SyntaxError: Cannot use import statement outside a module
解法。
// A map from regular expressions to paths to transformers
transform: {
'\\.jsx?$': 'babel-jest',
}