Test case React For Component:
I am trying to write a test case which calls a function in .jsx file passing object as argument from spec.js file to test a function return value of react component.
I have the pasted the code and error message, I am getting.
What could be cause for the error? any workaround to solve the error?
Below is the Test case code:
it(‘should render without problems OverlayAddExtraSimComponent restrictedtemplate type’, () => {
let overlayAddExtraSimObj = {code:‘AddOneExtraSimChange_ProductChangeButtons_TechnicalCategorization’},
overlayAddExtraSimVal;
overlayAddExtraSimVal = addExtraSim._restrictedToBundleTemplate(overlayAddExtraSimObj);
expect(overlayAddExtraSimVal).to.match('AddOneExtraSimChange');
});
Below is the Error Message:
FAILED TESTS: OverlayAddExtraSim Component × should render without problems OverlayAddExtraSimComponent restrictedtempl ate type PhantomJS 2.1.1 (Windows 7 0.0.0) undefined is not a constructor (evaluating ‘re.exec(obj)’) assertMatch@node_modules/chai/chai.js:1364:16 node_modules/chai/chai.js:4192:30 webpack:///src/components/overlay/overlay-add-extra-sim/overlay-add-extra-sim.spec.js:45:41 <- test/loadtests.js:279945:41
Note: I have tried installing phantomjs-polyfill-object-assign,babel-polyfill.
Kindly let me know, what could be the cause for this error and solution for it. Thanks in Advance.