I have a Jest test suite that fails to run because the component it's trying to test depends on a RequireJS module. Here's the error I'm seeing:
FAIL __tests__/components/MyComponent.test.js
● Test suite failed to run
ReferenceError: define is not defined
at Object.<anonymous> (node_modules/private-npm-module/utils.js:1:90)
The component has the following import:
import utils from 'private-npm-module';
And the private-npm-module
is set up like so:
define('utils', [], function() {
return {};
});
When MyComponent
is transpiled with babel and run in the browser, the dependency operates correctly. This issue only affects the unit test. How can I get my test suite to run on a component with a RequireJS dependency?
I'm using babel-jest
as my scriptPreprocessor
in package.json's jest config. I'm using jest v0.15.1.