Когда я запускаю «npm test» локально, все мои тесты работают нормально, без проблем. Однако, когда я пытаюсь запустить свои тесты на CircleCI, я получаю сообщение об ошибке ...
import React from 'react';
^^^^^
SyntaxError: Unexpected identifier
at Runtime._execModule (node_modules/jest-runtime/build/index.js:988:58)
Я не уверен, где лежит расхождение между этими двумя. Вот мой пакет. json
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"eject": "expo eject",
"test": "jest"
},
"dependencies": {
"@aws-amplify/api": "^1.2.4",
"@aws-amplify/pubsub": "^1.2.4",
"aws-amplify": "^2.2.2",
"aws-amplify-react": "^2.5.4",
"aws-amplify-react-native": "^3.2.0",
"expo": "^35.0.0",
"react": "16.8.3",
"react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz",
"react-native-gesture-handler": "~1.3.0",
"react-native-modal-dropdown": "^0.7.0",
"react-native-reanimated": "~1.2.0",
"react-native-screens": "^2.0.0-alpha.32",
"react-native-svg": "9.9.5",
"react-native-vector-icons": "^6.6.0",
"react-native-web": "^0.11.7",
"react-navigation": "^4.0.10",
"react-navigation-stack": "^1.10.3",
"react-navigation-tabs": "^2.6.0",
"victory-native": "^33.0.0"
},
"devDependencies": {
"babel-preset-expo": "^7.1.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"enzyme-react-16-adapter-setup": "^0.1.0",
"enzyme-to-json": "^3.4.3",
"jest": "^24.9.0",
"jest-enzyme": "^7.1.2",
"react-dom": "^16.8.3"
},
"private": true,
"jest": {
"preset": "react-native",
"collectCoverage": true,
"moduleDirectories": [
"node_modules",
"src"
],
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
},
"setupFiles": [
"<rootDir>/jest/setup.js"
],
"transformIgnorePatterns": [
"node_modules/(?!(jest-)?react-native|victory-.*)"
],
"coveragePathIgnorePatterns": [
"/node_modules/",
"/jest"
]
}
}
, а вот мой файл CircleCI .yml ...
version: 2.2
jobs:
build:
docker:
- image: circleci/node:10.15
working_directory: ~/repo/my-app
steps:
- checkout
# Download and cache dependencies
- restore_cache:
keys:
- v2.2-dependencies-{{ checksum "package.json" }}
# fallback to using the latest cache if no exact match is found
- v2.2-dependencies-
- run: npm install
- save_cache:
paths:
- node_modules
key: v2.2-dependencies-{{ checksum "package.json" }}
# run tests!
- run: npm test
Кажется, потому что я "npm устанавливаю", все Элементы React и Jest должны работать нормально. Есть идеи, если моя конфигурация выключена?