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

Question: injectEnvironment can only be called once - Jest #559

Closed
JamieDixon opened this issue Sep 3, 2016 · 1 comment
Closed

Question: injectEnvironment can only be called once - Jest #559

JamieDixon opened this issue Sep 3, 2016 · 1 comment

Comments

@JamieDixon
Copy link

JamieDixon commented Sep 3, 2016

I believe this issue will be fixed when React 15.4 is released as per facebook/react#7386 (comment)

I just want to check this is indeed the case and that there's no another issue causing this error that could be fixed in create-react-app.

How to reproduce:

  1. npm install velocity-react
  2. Create a component that utilized velocity-react:
<div>
     <VelocityTransitionGroup
         enter={{ animation: { opacity: 1 }, duration: 200 }}
         leave={{ animation: { opacity: 0 }, duration: 200 }}
         runOnMount
       >
          <div />
       </VelocityTransitionGroup>
</div>
  1. Write a Jest snapshot test that checks that this component renders correctly:
it('renders correctly', () => {
    const tree = renderer.create(
        <Component />
    ).toJSON();

    expect(tree).toMatchSnapshot();
});
  1. Observe the error in the console

Invariant Violation: ReactCompositeComponent: injectEnvironment() can only be called once.

@JamieDixon JamieDixon changed the title Question: injectEnvironment can only be called once Question: injectEnvironment can only be called once - Jest Sep 3, 2016
@gaearon
Copy link
Contributor

gaearon commented Sep 3, 2016

Yes, 15.4.0 should fix it, this is indeed a React issue.

@gaearon gaearon closed this as completed Sep 3, 2016
@lock lock bot locked and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants