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

Switch from tape to jest #1443

Closed
1 of 19 tasks
outoftime opened this issue May 4, 2018 · 0 comments
Closed
1 of 19 tasks

Switch from tape to jest #1443

outoftime opened this issue May 4, 2018 · 0 comments

Comments

@outoftime
Copy link
Contributor

outoftime commented May 4, 2018

Jest has become the pretty clear favorite for testing the kind of JavaScript application that Popcode is. I’ve never been amazingly happy with tape anyway, so let’s switch to the framework that will be most familiar to contributors.

Also, the new tests should avoid repeating the mistakes I made in structuring the old test suite. Specifically:

  • The reducer tests use the reducerTest helper function, which takes a before-state, an action, and an expected after-state. This however does not match the way one naturally thinks about testing reducers, namely: start with this state; apply this action; then make specific assertions about the resulting state (rather than just saying “this is what the resulting state should be”).
  • Reusable test helpers, particularly for creating test data, are unintuitive and not well-structured. We should have factory modules for each category of object we’d like to create: e.g., one for objects that the Firebase SDK would give us; one for objects that the GitHub API would give us; etc. We should use something like rosie to make factories simple to build and easy to extend.
  • Test code should not do direct manipulation on Redux state data structures. Redux state used in tests should always be generated by running a series of actions through the reducers. We should have a helper module to make this boilerplate-free.

Tests to migrate

Reducers

  • clients
  • compiledProjects
  • console
  • currentProject
  • errors
  • googleClassroom
  • index
  • projects
  • resizableFlex
  • ui
  • user

Sagas

Test should be ported as part of migration to redux-logic.

Validations

Validation tests will likely involve no major changes other than moving from Tape to Jest. So it might be worth exploring the use of a codemod to do this automatically.

  • html
  • css
  • javascript

Miscellaneous

Other Tape tests that can be found in test/unit:

  • higherOrderComponents/resizableFlex/calculateFlexGrowAfterDrag
  • localization/localization
  • Analyzer
  • util/javascript
  • util/queryParams
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants