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: flow + jest #3904

Closed
gsar-mdsol opened this Issue Jan 23, 2018 · 5 comments

Comments

Projects
None yet
7 participants
@gsar-mdsol

gsar-mdsol commented Jan 23, 2018

Do someone have a quick idea how to force flow-typed to install the definitions of jest? I do not see this mentioned in the README, and as jest is not a dependency of my project flow-typed install does not help much.

@gaearon gaearon self-assigned this Jan 23, 2018

@mcjohnalds

This comment has been minimized.

mcjohnalds commented Feb 11, 2018

  1. Look at yarn.lock to see which version of jest your project is using, in my case it was 20.0.4
  2. yarn add jest@20.0.4 && flow-typed install

It's important to only install the version of jest that CRA is already using otherwise yarn test will error.

@dashed

This comment has been minimized.

dashed commented Feb 21, 2018

@mcjohnalds

It's better to have a peerDependency in your package.json:

  "peerDependencies": {
    "jest": "20.x"
  },

Then flow-typed update --skip

@marcusegues

This comment has been minimized.

marcusegues commented Apr 6, 2018

To solve (temporarily I think) the issue of Flow finding errors in a Jest test file with the // @flow annotation at the top, I did:
npm install -g flow-typed
flow-typed install jest@20.0.4

When create-react-app is upgraded to use a new version of Jest, I would have to get the potential new type definitions by running the flowtyped install command above, correct? Is this intended? Isn't CRA supposed to work out of the box without this sort of thing?

@tylerthehaas

This comment has been minimized.

tylerthehaas commented May 31, 2018

I think the issue here is there is no way for flow-typed to install the dependencies of react-scripts which is where jest is pulled in from. This could be alleviated if there was a script added that did this likenpm run flow-typed. However it seems that the current thinking is to only have a very limited number of npm scripts included with create-react-app. Would be nice to have a solution to where we didn't have to include dependencies we wanted flow types for twice. Once in our own project dependencies and once by react-scripts.

@stale

This comment has been minimized.

stale bot commented Nov 2, 2018

This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 7 days if no further activity occurs.

@stale stale bot added the stale label Nov 2, 2018

@Timer Timer closed this Nov 2, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment