Following is my spec file for the unit testing of the react component (helloworld.spec.js):
import React from 'react';
import ReactTestUtils from 'react-dom/test-utils'; // ES6
import {HelloWorld} from './helloworld';
describe("HelloWorld Test",function(){
it("check header", function(){
var component = ReactTestUtils.renderIntoDocument(
<HelloWorld />
);
var eventRow = TestUtils.findRenderedDOMComponentWithTag(
component, 'h1'
);
expect(eventRow.getDOMNode().textContent)
.toEqual("template header");
});
});
And here is the helloworld.js:
import React from 'react';
export class HelloWorld extends React.Component{
render(){
return(
<h1>Hello World!</h1>
)
}
}
I have setup karma and jasmine for the unit testing and getting the error :
{ "message": "Uncaught ReferenceError: require is not defined\nat src/components/hello-world/helloworld.spec.js:3:14\n\nReferenceError: require is not defined\n at src/components/hello-world/helloworld.spec.js:3:14", "str": "Uncaught ReferenceError: require is not defined\nat src/components/hello-world/helloworld.spec.js:3:14\n\nReferenceError: require is not defined\n at src/components/hello-world/helloworld.spec.js:3:14" }
But I don't see require in the code so how come it's not defined. Any leads for where the issue could be, probably a config one?