vendredi 2 octobre 2015

Testing Material-UI with jest is slow

I use reactjs and material-ui for my application. For unit testing I use jest.

Versions:

react: 0.13.3
material-ui: 0.12.1
jest-cli: 0.5.8

If I use a material-ui in a React.Component my jest test is really slow.

Example 1:

var React    = require('react');

module.exports = React.createClass({

    render: function () {
        return (<div></div>);
    }

});

Test takes 0.5 seconds.

Example 2:

var React    = require('react');
var Material = require('material-ui');

module.exports = React.createClass({

    render: function () {
        return (<div></div>);
    }

});

Test takes 25 seconds.

What I have tried/experienced so far:

  • It doesn't make a difference if I turn mocking off/on for
    material-ui.
  • It doesn't matter if I use a material-ui component or not. Requiring seems to be the bottleneck.
  • If have used two different preprocessors: react-tools, babel-jest

Does anyone have the same problem? Or better a solution?

Aucun commentaire:

Enregistrer un commentaire