Я использую нашу собственную библиотеку для вызовов API. В devDependencies я указал эту библиотеку. Если я запускаю npm install, я получу библиотеку в node_modules. Приложение на стороне работает нормально.
Когда я пытаюсь работать с JEST, я получил неожиданный токен.
пожалуйста, найдите ниже моего package.json,
{
"name": "myApp",
"version": "0.28.9",
"description": "My APP",
"main": "index.js",
"scripts": {
"test": "jest --verbose",
"build": "babel index.js"
},
"dependencies": {
"@test/myAPI": "*",
"jest-cli": "^23.6.0",
"react-native-linear-gradient": "^2.3.0",
"react-native-popup-dialog": "^0.9.39",
"react-navigation": "^1.0.0-beta.27",
},
"devDependencies": {
"babel-jest": "^22.4.4",
"babel-plugin-transform-export-extensions": "^6.22.0",
"babel-preset-react-native": "^4.0.0",
"isomorphic-fetch": "^2.2.1",
"jest": "22.1.2",
"react": "^16.3.1",
"react-native": "^0.55.4",
"react-test-renderer": "16.2.0"
},
"jest": {
"preset": "react-native"
}
}
```
```
.babelrc
{
"presets": ["react-native"]
}
```
Form the Jest, I ran the test. Then I got the following Error.
```
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){export {
^^^^^^
SyntaxError: Unexpected token export
11 | } from "../data-providers";
12 | import * as lString from "../../lang_en.json";
> 13 | import { getAuthenticationInfo, submitRegistertrationResponse, ERROR } from "@test/myAPI";
| ^
14 |
15 |
16 | Date.prototype.monthNames = [
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)
at Object.<anonymous> (src/helpers/utils.js:13:1)
at Object.<anonymous> (src/containers/RegistrationView/index.js:15:1)
```