3

I'm implementing (or trying to implement) unit/functional tests for our app and would like to use InternJS as a test runner with the Enzyme testing utility.

To unit test our components the JSX needs to be transpiled. The Intern docs contain a React example but with the deprecation of JSXTransformer the example is no longer relevant.

So I've tried to use Babel via the SystemJS plugin, systemjs-plugin-babel and used the recommended loader configuration.

When I run the tests the following error occurs:

$ node_modules/.bin/intern-client config=tests/config/local
Error: (SystemJS) SyntaxError: Unexpected token < at Object.exports.runInThisContext (vm.js:53:16)
Evaluating path/to/tests/unit/button.test.js
Error loading path/to/tests/unit/button.test.js
No stack or location

Removing the JSX from the tests shows the error is related to the JSX in the tests.

Is it possible to use Intern with Enzyme to test React components? And if so, how do you configure Intern to prep the components for testing?

Brett DeWoody
  • 59,771
  • 29
  • 135
  • 184

0 Answers0