Jest connectStyle Error
See original GitHub issueI have gone through these following points
- Check latest documentation: https://docs.nativebase.io/
- Check for existing open/closed issues for a possible duplicate before creating a new issue: https://github.com/GeekyAnts/NativeBase/issues
- Use the latest NativeBase release: https://github.com/GeekyAnts/NativeBase/releases
- Check examples from NativeBase KitchenSink https://github.com/GeekyAnts/NativeBase-KitchenSink
- [] For discussion purpose make use of NativeBase Slack: http://slack.nativebase.io/
- [] For queries related to theme, check Theme Variables from Docs and live NativeBase Theme Editor http://nativebase.io/customizer/
Issue Description
import React from 'react'
import Route from '../route'
import renderer from 'react-test-renderer'
test('renders correctly', () => {
const tree = renderer.create(<Route />).toJSON();
expect(tree).toMatchSnapshot();
});
The app working properly in normal case. But when I started jest, it gave an error like this: `Test suite failed to run
XXX\node_modules\native-base-shoutem-theme\index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import connectStyle from "./src/connectStyle";
^^^^^^^^^^^^
SyntaxError: Unexpected identifier
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/ScriptTransformer.js:440:17)
at Object.<anonymous> (node_modules/native-base/src/index.js:1:1)`
node, npm, react-native, react and native-base version, expo version if used, xcode version
node: v10.15.1
npm: 6.4.1
"expo": "^31.0.4",
"native-base": "^2.8.1",
"react": "^16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-31.0.1.tar.gz",
Expected behaviour
Passing test processing
Actual behaviour
Gives the error
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Jest - react-native SyntaxError: Unexpected token import
Jest encountered an unexpected token This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not...
Read more >undefined. jest - You.com | The AI Search Engine You Control
Error: Cannot create styled-component for component: undefined ... React Jest Testing TypeError: Cannot read properties of undefined (reading 'current').
Read more >VScode-jest: The Optimal Flow for Jest Based Testing in VS ...
VScode-jest: The optimal flow for Jest based testing in VS Code. Jest - Visual Studio Marketplace & click "Install". Alternatively open Visual Studio...
Read more >Kiri, Bang! on Tumblr
src/connectStyle'; ... There has been a stack of error waiting for me. ... On testing, I encounter a problem where jest did not...
Read more >Developers - SyntaxError: Cannot use import statement outside a ...
... ,exports,require,__dirname,__filename,global,jest){import connectStyle, { clearThemeCache } from ". ... "@types/jest": "^24.9.0", ... Gives the error.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Same issue. Adding
to
package.json
solves the issue but greatly increases testing time. Haven’t found a better solution.i found out the solution, reading into the doc of jest, it can be figured out by avoiding transform packages in the npm folder.
notice: Im using react-native (no expo) and ignoring the native-base, react-native and react folders