-
Notifications
You must be signed in to change notification settings - Fork 140
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
Transition from redux-saga to redux-logic and using Jest to test - Part One #1655
Conversation
@outoftime Finished test for unlinkGithubIdentityTest. I tried to be thorough with testing the return. What do you think? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jwang1919 I think the approach looks solid overall. One high-level question I have is: should we strive to have one assertion per test? Some testing frameworks strongly prefer this, others do not; I am not sure where jest falls on that. Maybe it's worth quickly doing a survey of popular projects that use jest for testing (which is basically all of them)?
Also have some more line-level feedback but will hold off on that until you're ready for it.
Also I think $ git checkout master -- yarn.lock
$ yarn install
$ yarn deduplicate ? |
I'm not sure. I like to have multiple assertions in a test as long as they are all testing the same functionality. I usually like to group tests by happy paths, bad paths and edge cases. I will defer the answer to you since you have more jest experience. EDIT: Seems like the loud majority is to aim for one assertion per test to avoid Assertion Roulette. I still think the test is fine because the method itself is to unlinkGithub. It doesn't make sense to separate it into something like: "should unlink identity" and "should unlink from provider github.com".
Bring it on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lookin' good! Just a few line-level comments.
Also: can you update the PR title and description to reflect the current state of the world? Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment on package.json
—I’m also going to push a couple of changes to fix the linting failures and remove some unnecessary comments.
…gic. Still need to get react-saga and react-logic to play nicely.
These libraries are set up in code that runs at module load time, which is probably not a great practice, but for now we just mock out the libraries themselves so our modules will load without error.
@outoftime After the rebase with your Oh wait nm, I think I did an incorrect merge |
The issue now is that because jest is called as a global library, eslint is not happy with it. |
@jwang1919 i got u |
@outoftime I addressed the |
@jwang1919 checkin it out!! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
woop woop!
Converted only one saga method:
unlinkGithubCredentials
.Was able to get redux-saga and redux-logic working at the same time.
Did not complete the jest test because was trying to get it running correctly through IntelliJ, seems to run correctly when using
yarn test
.Still very much WIP.
Currently experiencing issues where
import
keyword is not recognized by jest.To reproduce the error, install jest globally and run
jest unlinkGithubCredentialsTest.js
.So far tried solutions listed here:
jestjs/jest#5920
jestjs/jest#2081