Open isabelacmor opened 5 years ago
got the same thing, on first trying a link, works after a reload...
removeClass.js:8 Uncaught TypeError: element.setAttribute is not a function
at removeClass (removeClass.js:8)
at CSSTransition.js:81
at Array.forEach (
"apollo-boost": "^0.1.23", "graphql": "^14.0.2", "node-sass": "^4.11.0", "react": "16.7.0", "react-apollo": "^2.3.3", "react-dom": "16.7.0", "react-router-dom": "^4.3.1", "react-scripts": "^2.1.3", "react-transition-group": "^2.5.2"
What does your test look like? I can't seem to find it in the CodeSandbox example.
Not sure if it's helpful, but I had the same error and was able to fix it by mocking react-transition-group
with jest
Any test examples where this error pops up?
a wrapper div around the component helped.
The problem seems to stem from using the deprecated findDOMNode
in Transition.js
, which ReactTestRenderer is publicly committed to not supporting. The "node" it returns does not work with the dom-helpers library.
@jquense @eps1lon This may be relevant to discussion on https://github.com/reactjs/react-transition-group/pull/457 about the priority of replacing findDOMNode? Assuming I've diagnosed the situation correctly.
In case anyone else hits the issue and wants a workaround, like those above I mocked out part of the library by adding the following to my Jest setup file:
import React from 'react';
const reactTransitionGroup = jest.requireActual('react-transition-group');
reactTransitionGroup.CSSTransition = ({ children }) => {
return <>
{children}
</>;
};
jest.setMock('react-transition-group', reactTransitionGroup);
Love to know what others did.
@alicederyn I'm missing a reproducible example. The codesandbox in the initial post does not include any tests (among other issues like mismatching versions between post and package.json). I'm not familiar with ReactTestRenderer so without code I could only guess.
@alicederyn your suggestion works but I am getting the following warning
Warning: Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.
@timurcatakli @alicederyn Any updates about this warning? How to remove this warning? Thanks in advance.
I could fix this warning by calling children
, i.e. rendering {children()}
in @alicederyn's mock.
Do you want to request a feature or report a bug? Report a bug
What is the current behavior? Jest tests failing with react-transition-group.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Here's a minimal demo of my code: https://codesandbox.io/s/4RAqrkRkn Everything runs fine in the browser, but when running my Jest tests, I get the above error.
What is the expected behavior? Getting a node similar to the following. This comes from another test for a component which users Router, but not react-transition-group.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React? "react": "^16.5.2", "react-dom": "^16.5.2", "react-transition-group": "2.5.1", "@types/react-transition-group": "^2.0.14",