[mocha test] SyntaxError: Unexpected token import

original 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)

2 thoughts on “[mocha test] SyntaxError: Unexpected token import

Comments are closed.