0

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.

Fabiano Tarlao
  • 3,024
  • 33
  • 40
  • I have not the answer but few suggestions, you have to improve all the question a lot. A well-written question has higher chances to get an answer. I think that the part that summarizes the "question", in your post, should be better highlighted (where is the ->?). You have done a lot of formatting errors--e.g: "code" format for normal text. This makes your question unreadable. – Fabiano Tarlao Apr 06 '18 at 07:42
  • Also try to better separate context/topic description, environment description, actions performed, expected outcome, obtained errors (.. I also give far far faar more informations), and the question. You have to spend more time creating the question or people is not going to spend their time answering. – Fabiano Tarlao Apr 06 '18 at 07:43
  • Hope now you understand – pradeepkumar Apr 06 '18 at 13:35

0 Answers0