Skip to content
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

unit test fails when component under test imoports a <Link> component from Gatsby #34

Closed
thescientist13 opened this issue Mar 26, 2018 · 3 comments
Assignees
Labels
blocked chore build stuff, deploy stuff, etc etc help wanted Extra attention is needed

Comments

@thescientist13
Copy link
Member

So if you enable the

component specs, this error will show in the terminal

 FAIL  src/components/header/header.spec.jsx
  Header Component
    ✕ should not be null (33ms)

  ● Header Component › should not be null

    TypeError: Cannot read property 'history' of undefined

      10 |
      11 |   beforeEach(() => {
    > 12 |     header = mount(<Header/>);
      13 |   });
      14 |
      15 |   // TODO fix why bombs out because of <Link> being used in the component

      at new GatsbyLink (node_modules/gatsby-link/index.js:107:34)
      at node_modules/react-dom/lib/ReactCompositeComponent.js:292:18
      at measureLifeCyclePerf (node_modules/react-dom/lib/ReactCompositeComponent.js:73:12)

This is the same for any other component, and seems to have to do something with Gatsby providing some sort of functionality under the hood in the app?

Anyway, solving this would be ideal since it is preventing the app from having better code coverage.

@thescientist13 thescientist13 added help wanted Extra attention is needed chore build stuff, deploy stuff, etc etc labels Mar 26, 2018
@thescientist13
Copy link
Member Author

thescientist13 commented Mar 26, 2018

This is line 107, so seems like some sort of Routing is expected?

var history = context.router.history;

@thescientist13
Copy link
Member Author

commented on an open issue with Gastby + Jest here

@thescientist13
Copy link
Member Author

resolved as part of #82 / #85

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked chore build stuff, deploy stuff, etc etc help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant