-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DocumentTitle is undefined when running tests #58
Comments
@Birne94 hello, I've had exactly the same issue with Jest. The code is working perfectly on the browser but impossible to run the tests with Jest. It looks like it's an import/export issue. I've been able to make it work by importing the import * as DocumentTitle from 'react-document-title'; |
works as a workaround for me, I can't get any of the |
@bladedeyna then you can use only ts-ignore... doesn't make sense to use require |
When using this library with TypeScript, I am encountering errors when running tests:
My typings file:
This code runs perfectly fine when executed on the server, but during testing it fails:
Invariant Violation: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.
Debugging shows that the import of
react-document-title
simply returnsundefined
when using jest, but the proper class when running the server.Does anybody know what might be the cause of this?
The text was updated successfully, but these errors were encountered: