Closed ashwinsaval closed 5 years ago
@plougsgaard need some help here.
Okay I seem to have found the issue but it still needs a resolution, since I currently have to hack the usage of react-timeout
to make it work in my tests. Surprisingly, react-timeout works fine in dev environment but not in tests. Here are my observations:
Typescript + Jest + Enzyme
import ReactTimeout from 'react-timeout';
class MyClass {
...
}
export default ReactTimeout(MyClass)
When using in dev environment, everything works fine. However, when attempting to run a simple test with my component, I get the following error:
TypeError: react_timeout_1.default is not a function
Looking at Issue https://github.com/Microsoft/TypeScript/issues/3019, it looks like the issue is with a missing .d.ts
typescript definition file in the project.
We are currently working around this issue by using all imports in the following way, however it is not the final solution:
const ReactTimeout = require('react-timeout');
I would love to hear of the proper resolution of this issue and what can be done.
@ashwinsaval
I've just been on holiday so didn't see your issue until now.
Looking at the issue you reference it seems like TypeScript needs the definition files from somewhere, and I'd be happy to add them to this project if it means greater compatibility.
If you're familiar with how to write them you could see if putting a .d.ts
inside node_modules/react-timeout
fixes your problem. As I don't have a reproducible test case that fails it would probably take me a while. 😄
Thanks for bringing this to attention!
Is this just a DEV issue? Are we OK with production? I am worried whether things will break in production. Thanks!
Hi, My Jest test cases are failing with the following error:
The test case is a simple render and check if the component is loading fine. Any reason why I am facing this error while testing?