'How is it possible to make mocha work without having to use commonJS?
I am currently trying to learn how testing works and how to do it with mocha on react native. This is a test from a tutorial I found:
import React from 'react';
import Enzyme, { shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { Text } from 'react-native';
import { expect } from 'chai';
import App from './App';
Enzyme.configure({ adapter: new Adapter() });
describe('<App>', () => {
let wrapper;
beforeEach(() => {
wrapper = shallow(<App />);
});
it('renders default Text', () => {
expect(wrapper.find(Text)).to.have.lengthOf(3);
});
});
My problem is that whenever I run the test I get his back:
import React from 'react';
^^^^^^
SyntaxError: Cannot use import statement outside a module
When I change the import statements to require, I then get this error:
wrapper = shallow(<App />);
^
SyntaxError: Unexpected token '<'
I don't really understand how I can make mocha work on react native... or could someone recommend some resources please?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
