-
Notifications
You must be signed in to change notification settings - Fork 103
Open
Description
When using this library with TypeScript, I am encountering errors when running tests:
import DocumentTitle from 'react-document-title';
// ...
renderToString(
<DocumentTitle title="Hello World">
<AppComponen/>
</DocumentTitle>
);My typings file:
// @types/react-document-title.d.ts
declare module 'react-document-title' {
import * as React from 'react';
interface DocumentTitleProps {
title: string;
}
export default class DocumentTitle extends React.Component<DocumentTitleProps, any> {
public static rewind(): string;
public static peek(): string;
}
}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 returns undefined when using jest, but the proper class when running the server.
Does anybody know what might be the cause of this?
alonrbar
Metadata
Metadata
Assignees
Labels
No labels