profiler icon indicating copy to clipboard operation
profiler copied to clipboard

Add tests for our complex flow typing

Open gregtatum opened this issue 7 years ago • 3 comments

We should add some tests to make sure our typing works. My guess is that this broke in the recent Flow upgrade.

┆Issue is synchronized with this Jira Task

gregtatum avatar Mar 06 '18 16:03 gregtatum

Hmm... actually never mind. I misspelled mapStateToProps, and it didn't throw errors. Looking at the type definition, it makes sense why it wouldn't.

gregtatum avatar Mar 06 '18 16:03 gregtatum

Reopening because I believe this is still something we need. It would give us more confidence when changing these complex typings as well as when upgrading flow.

Some key things from my previous research to do this:

  • add a custom suppress_comment to .flowconfig so that we have a more explicit comment than $FlowFixMe for tests; maybe $ExpectError is a good idea (like flow-typed does). If we specify such a comment but there's no Flow error at this location, Flow will generate a warning.
  • use the argument --max-warnings 0 when running Flow, so that warnings actually fail flow. (Note: this is new in Flow, before we had to parse Flow's output... Good we don't have to do that now :+1: )
  • add a directory src/test/flow to put the code samples
  • it's especially important to add code samples that trigger flow errors, but please also add code samples that are correct. We already do have code samples that are correct in the app code, but it's always easier to debug flow issues with simpler code than with the full app code.

Things to especially check:

  • [x] explicitConnect (from src/utils/connect.js)
  • [ ] HOC withSize (from src/components/shared/WithSize.js)
  • [ ] HOC withViewport (from src/components/shared/chart/Viewport.js)
  • [ ] (optional) ButtonWithPanel (from src/components/shared/ButtonWithPanel.js)

julienw avatar Mar 07 '18 10:03 julienw

We have tests now for the connect.js function.

gregtatum avatar Mar 06 '19 21:03 gregtatum