I have a react application that doesn't uses the browserify tool.
It means that the React
variable is exported by the script of the react js lib called in the <head>
.
// React variable is already available
var MyComponent = React.createClass({});
After implementing this component, I want to create a test for it. I took a look at Jest documentation and I've created my component test.
/** @jsx React.DOM */
jest.dontMock('../compiled_jsx/components/my-component.js');
describe('MyComponent', function() {
it('The variables are being passed to component', function() {
var React = require('react/addons');
// In the `MyComponent` import I got the error below:
// ReferenceError: /compiled_jsx/components/my-component.js: React is not defined
var myComponent = require('../compiled_jsx/components/my-component.js');
});
In the Jest documentation example, both component and its tests uses the require
function for getting the React
variable.
Is there any way to expose React
variable into the component?
Or it's necessary using browserify for creating this test?