[mocha test] SyntaxError: Unexpected token import
See original GitHub issueoriginal source,
import React from 'react';
import {
View,
Text,
} from 'react-native';
const ChatList = () => (
<View>
<Text>Hello world</Text>
</View>
);
export default ChatList;
mocha test runs fine.
after i added this code,
import { Container, Header, Content, Footer, Title } from 'native-base';
and run mocha test,
it throws
mocha --require react-native-mock/mock.js --compilers js:babel-core/register src/*/.t est.js --watch
SyntaxError: Unexpected token import
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Module._extensions..js (module.js:405:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/canna/my-projects/
mshopbang/node_modules/babel-register/lib/node.js:166:7)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (ChatList.js:6:1)
at Module._compile (module.js:398:26)
at loader (/Users/canna/my-projects/mshopbang/node_modules/babel-register/lib/node.js
:158:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/canna/my-projects/
mshopbang/node_modules/babel-register/lib/node.js:168:7)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:5
Top Results From Across the Web
Babel unexpected token import when running mocha tests
For Babel <6. The easiest way to solve this problem is: npm install babel-preset-es2015 --save-dev. Add .babelrc to the root of the project...
Read more >SyntaxError: Unexpected token import · Issue #3228 - GitHub
I am getting this error while running test by mocha test --reporter mocha-junit-reporter . Is anything wrong I am doing here?
Read more >mochajs/mocha - Gitter
{ import * as Foo from '../src/common/foo'; ^ SyntaxError: Unexpected token * with "test": "mocha --require ts-node/register --require ...
Read more >Chai test fail with "Unexpected import token"
Hi guys,. I have a project which uses mocha chai unit tests. They work just fine when I run them on the command...
Read more >Babel unexpected token import when running mocha tests
So if you haven't already, make sure you do npm install mocha -g . Then just run mocha in your project's root directory....
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
Did you solve this issue? If yes can you share your solution?
I’m having the same problem right now, any solution for that?