I would like to use Chimp, with Mocha and Enzyme, for testing React components. However, I tried re-creating the setup described by @ffxsam for doing this, but instead using Chimp as the test runner, and am getting a unexpected token
error.
The test
import React from 'react';
import { expect } from 'chai';
import { shallow } from 'enzyme';
import Thing from '../client/components/thing';
describe('<Thing />', function () {
it('contains a div with class abc and a hello message', function () {
expect(shallow(<Thing />).contains(<div className="abc">Hi</div>)).to.equal(true);
});
});
The error I am getting
> chimp --ddp=http://localhost:3000 --mocha --watch --path=tests
[chimp] Watching features with tagged with @focus,@dev,@watch
[chimp] Running...
/usr/local/lib/node_modules/chimp/dist/lib/mocha/mocha-wrapper.js:56
throw e;
^
SyntaxError: /Users/Anders/dev/explore/meteor/testing/meteor-chimp/app/tests/react_test.js: Unexpected token (8:19)
6 | describe('<Thing />', function () {
7 | it('contains a div with class abc and a hello message', function () {
> 8 | expect(shallow(<Thing />).contains(<div className="abc">Hi</div>)).to.equal(true);
| ^
9 | });
10 | });
at Parser.pp.raise (/usr/local/lib/node_modules/chimp/node_modules/babylon/lib/parser/location.js:22:13)
at Parser.pp.unexpected (/usr/local/lib/node_modules/chimp/node_modules/babylon/lib/parser/util.js:89:8)
at Parser.pp.parseExprAtom (/usr/local/lib/node_modules/chimp/node_modules/babylon/lib/parser/expression.js:517:12)
at Parser.pp.parseExprSubscripts (/usr/local/lib/node_modules/chimp/node_modules/babylon/lib/parser/expression.js:272:19)
at Parser.pp.parseMaybeUnary (/usr/local/lib/node_modules/chimp/node_modules/babylon/lib/parser/expression.js:252:19)
at Parser.pp.parseExprOps (/usr/local/lib/node_modules/chimp/node_modules/babylon/lib/parser/expression.js:183:19)
at Parser.pp.parseMaybeConditional (/usr/local/lib/node_modules/chimp/node_modules/babylon/lib/parser/expression.js:165:19)
at Parser.pp.parseMaybeAssign (/usr/local/lib/node_modules/chimp/node_modules/babylon/lib/parser/expression.js:128:19)
at Parser.pp.parseExprListItem (/usr/local/lib/node_modules/chimp/node_modules/babylon/lib/parser/expression.js:1032:16)
at Parser.pp.parseCallExpressionArguments (/usr/local/lib/node_modules/chimp/node_modules/babylon/lib/parser/expression.js:348:20)
at Parser.pp.parseSubscripts (/usr/local/lib/node_modules/chimp/node_modules/babylon/lib/parser/expression.js:311:31)
at Parser.pp.parseExprSubscripts (/usr/local/lib/node_modules/chimp/node_modules/babylon/lib/parser/expression.js:282:15)
at Parser.pp.parseMaybeUnary (/usr/local/lib/node_modules/chimp/node_modules/babylon/lib/parser/expression.js:252:19)
at Parser.pp.parseExprOps (/usr/local/lib/node_modules/chimp/node_modules/babylon/lib/parser/expression.js:183:19)
at Parser.pp.parseMaybeConditional (/usr/local/lib/node_modules/chimp/node_modules/babylon/lib/parser/expression.js:165:19)
at Parser.pp.parseMaybeAssign (/usr/local/lib/node_modules/chimp/node_modules/babylon/lib/parser/expression.js:128:19)
^C
Here is a repo with the entire test and setup.