lundi 29 octobre 2018

Testing React Component which has material UI using Enzyme and Jest

My component has the following imports from material ui in react 
component

     import Dialog from '@material-ui/core/Dialog';
     import DialogContent from '@material-ui/core/DialogContent';
     import { withStyles } from '@material-ui/core/styles';


While I wrote my testcases with enzyme and jest I could see the 
below error while running the testcase.Is that happens due to the material 
ui dialog and how should I mock if in case it need to be used. 

      Test suite failed to run

      TypeError: (0 , _ponyfill2.default) is not a function

     1 | import './login.css';
     2 | import React, { Component } from 'react';
     > 3 | import Dialog from '@material-ui/core/Dialog';
         | ^
     4 | import DialogContent from '@material-ui/core/DialogContent';
     5 | import { withStyles } from '@material-ui/core/styles';
     6 | import { Redirect } from "react-router-dom";

      at Object.<anonymous> (node_modules/jss/node_modules/symbol- 
      observable/lib/index.js:28:40)
     at Object.<anonymous> (node_modules/jss/lib/utils/isObservable.js:7:25)
     at Object.<anonymous> (node_modules/jss/lib/utils/cloneStyle.js:11:21)
     at Object.<anonymous> (node_modules/jss/lib/utils/createRule.js:16:19)
     at Object.<anonymous> (node_modules/jss/lib/RuleList.js:11:19)  

My package.json: "babel-cli": "6.26.0", "babel-core": "6.26.0", "babel-eslint": "8.2.6", "babel-jest": "^23.4.2", "babel-polyfill": "^6.26.0", "enzyme": "^3.4.4", "enzyme-adapter-react-16": "^1.2.0", "jest": "^23.5.0",

Can anyone let me know why the error happening.

Aucun commentaire:

Enregistrer un commentaire