弹出的Create-React-App无法从Atlaskit软件包中移植node_modules代码

时间:2019-04-19 15:44:26

标签: reactjs jestjs node-modules create-react-app atlaskit

{p {1}}中的

Atlaskit软件包导致Jest在弹出的create-react-app中失败。到目前为止,我只有默认的@Override protected void onPause () { super.onPause(); try { // Modes: MODE_PRIVATE, MODE_WORLD_READABLE, MODE_WORLD_WRITABLE FileOutputStream output = openFileOutput("latlngpoints.txt", Context.MODE_PRIVATE); DataOutputStream dout = new DataOutputStream(output); dout.writeInt(listPoints.size()); // Save line count for (LatLng point : listPoints) { dout.writeUTF(point.latitude + "," + point.longitude); Log.v("write", point.latitude + "," + point.longitude); } dout.flush(); // Flush stream ... dout.close(); // ... and close. } catch (IOException exc) { exc.printStackTrace(); } } protected void onResume (GoogleMap googleMap){ super.onResume(); try { FileInputStream input = openFileInput("latlngpoints.txt"); DataInputStream din = new DataInputStream(input); int sz = din.readInt(); // Read line count for (int i = 0; i < sz; i++) { String str = din.readUTF(); String[] stringArray = str.split(","); double latitude = Double.parseDouble(stringArray[0]); double longitude = Double.parseDouble(stringArray[1]); // newlist.add(new LatLng(latitude, longitude)); Log.v("Read", String.valueOf(latitude)); Log.v("Read1", String.valueOf(longitude)); LatLng latLng = new LatLng(Double.parseDouble(stringArray[0]), Double.parseDouble(stringArray[1])); mMap1 = googleMap; mMap1.addCircle(new CircleOptions() .center(latLng) .radius(100) .strokeColor(Color.RED)); } din.close(); } catch (IOException exc) { exc.printStackTrace(); } } 文件,并且从node_modules收到App.test.js

Image of Error

我已经查看了关于StackOverflow和Github问题的所有不同问题,尽管每个人都一直建议尝试的标准答案是专注于Jest配置中的SyntaxError: Unexpected token export,但我尝试做的似乎都没有技巧,所以这可能是一个单独的问题。

@atlaskit/dropdown-menu中,我当前的Jest配置如下。这是弹出后显示的默认配置:

package.json

transformIgnorePatterns

我还从package.json中删除了"jest": { "collectCoverageFrom": [ "src/**/*.{js,jsx,ts,tsx}", "!src/**/*.d.ts" ], "resolver": "jest-pnp-resolver", "setupFiles": [ "react-app-polyfill/jsdom" ], "testMatch": [ "<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}", "<rootDir>/src/**/?(*.)(spec|test).{js,jsx,ts,tsx}" ], "testEnvironment": "jsdom", "testURL": "http://localhost", "transform": { "^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest", "^.+\\.css$": "<rootDir>/config/jest/cssTransform.js", "^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js" }, "transformIgnorePatterns": [ "[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$", "^.+\\.module\\.(css|sass|scss)$" ], "moduleNameMapper": { "^react-native$": "react-native-web", "^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy" }, "moduleFileExtensions": [ "web.js", "js", "web.ts", "ts", "web.tsx", "tsx", "json", "web.jsx", "jsx", "node" ] } 配置和babel并放入了自己的单独文件中。

.babelrc.js

eslint

.eslintrc.json

package.json

我希望,当调用const plugins = [ [ "module-resolver", { root: [ "." ], alias: { atoms: "./src/components/atoms", molecules: "./src/components/molecules", organisms: "./src/components/organisms", pages: "./src/components/pages" } } ] ] module.exports = { env: { development: { presets: ["react-app"], plugins, }, local: { presets: ["react-app"], plugins, }, qa: { presets: ["react-app"], plugins, }, stage: { presets: ["react-app"], plugins, }, production: { presets: ["react-app"], plugins, }, test: { presets: [ ["react-app", { 'preset-env': { 'modules': 'commonjs' }} ] ], plugins, } } } 时,所有与之相关的 all { "extends": ["standard", "standard-react"], "env": { "browser": true, "es6": true, "jest": true }, "plugins": [ "standard", "react" ], "globals": { "Atomics": "readonly", "SharedArrayBuffer": "readonly" }, "parserOptions": { "ecmaFeatures": { "jsx": true, "javascript": true, "modules": true }, "ecmaVersion": 2018, "sourceType": "module" }, "rules": { } } 而不仅仅是npm run test都将被正确地转换为不会导致开玩笑失败。

0 个答案:

没有答案