Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Unable to test hooks that Suspend #27

Closed
Labels
bugSomething isn't working good first issueGood for newcomers
@ntucker

Description

  • react-hooks-testing-library version: 0.4.0
  • react-testing-library version: 6.0.3
  • react version: 16.8.6
  • node version: 11.10.0
  • npm (or yarn) version: 1.15.2

Relevant code or config:

import { useResource } from 'rest-hooks';
renderHook(() => {
 article = useResource(CoolerArticleResource.singleRequest(), payload);
 return article;
 })

What you did:

Running unit tests on 'rest-hook's library. Trying to update from react-testing-library - which works fine - to react-hooks-testing-library.

(https://github.com/coinbase/rest-hooks/blob/master/src/react-integration/__tests__/integration.tsx)

What happened:

Invariant Violation: Rendered more hooks than during the previous render.

Reproduction:

https://github.com/coinbase/rest-hooks/blob/update-test/src/react-integration/__tests__/integration.tsx#L167
(run yarn test on that branch)

Problem description:

Impossible to test hooks that use suspense. (This was fixed in React 16.8.2 facebook/react#14821)

Suggested solution:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working good first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /