-
Notifications
You must be signed in to change notification settings - Fork 1.3k
tests with withState + React.createRef() takes unusually long or hangs #669
Comments
And what you expect writing this here? |
I clicked the "Submit" button by accident. |
Do re-open. |
Possibly because enzyme still not support latests versions of React? |
I will add two more examples that might suggest otherwise. |
enzymejs/enzyme#1553 (comment) |
"enzyme": "^3.1.1", // Test.js
// No withState involvement, just a regular ref enabled stateless functional component.
import React from "react";
import PropTypes from "prop-types";
//import { withState } from "recompose";
// const enhance = withState("x", "setX", "hi");
export const _Test = ({ prop, x, setX }) => {
const rate = React.createRef();
return (
<div>
<input ref={rate} />
</div>
);
};
_Test.propTypes = {
prop: PropTypes.string.isRequired
};
export const Test = _Test;
// Test.js
// ref not being used in an input, but does have withState call
import React from "react";
import PropTypes from "prop-types";
import { withState } from "recompose";
const enhance = withState("x", "setX", "hi");
export const _Test = ({ prop, x, setX }) => {
const rate = React.createRef();
return (
<div>
hello, no input using refs here
</div>
);
};
_Test.propTypes = {
prop: PropTypes.string.isRequired
};
// export const Test = _Test;
export const Test = enhance(_Test);
|
@istarkov Good find, it may very well have to do with it. I will keep an eye on that issue then. |
IMO its enzyme problem, try to write tests using react test utils https://reactjs.org/docs/test-utils.html |
I have this problem with
"react": "^16.3.0",
"recompose": "^0.27.0",
"babel-jest": "^22.4.3",
when run with
jest Test.spec.js
it takes almost 5s and often time hangs forever.But with either 1) not using
withState
or 2) not usingref
, the test finishes in a reasonable 1.5s.Does anyone else have the same problem?
The text was updated successfully, but these errors were encountered: