-
Notifications
You must be signed in to change notification settings - Fork 8
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
Move to Jest Expect #6
Conversation
@tizmagik let me know if you need any changes on this |
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.
This is awesome, thank you! Especially for fixing that unhandled promise thing, that's great!
Do you think we can drop sinon
as well? I added a comment about Jest's built in "spy"-ability. Let me know what you think. Thanks!
tests/PromiseMiddleware.test.js
Outdated
|
||
actionHandler(actionObj); | ||
|
||
expect(actionSpy.calledOnce).toBeTruthy(); | ||
expect(actionSpy.firstCall.args[0]).toEqual(actionObj); |
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.
I think you can actually drop sinon
and get away with using Jest's built-in spy, jest.fn()
here and elsewhere. For example:
const actionSpy = jest.fn();
const actionHandler = nextHandler(actionSpy);
actionHandler(actionObj);
expect(actionSpy).toHaveBeenCalledTimes(1);
expect(actionSpy).toHaveBeenCalledWith(actionObj);
@tizmagik Jest mocks for the win. They actually reduced a few areas down a bit which was nice. I also fixed the skipped test in |
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.
Awesome work, thank you!
* Initial jest conversion * Remove macho setup and remove jsdom package. * PromiseMiddleware test refactor. * Refactor ReduxTaxi tests to jest expect * Refactor ReduxTaxiMiddleware test to jest expect * Refactor ReduxTaxiProvider to jest expect * Refactor RegisterAsyncActions test to jest expect * Remove chai package * Remove trailing commas * Add Prettier * Add Prettier * Update list-staged file catch * Run Prettier on all JS files * Remove sinon in favor for jest mocks. * removing prettier deps from this PR. * packages. * Prettier pre-hook and reformat current files. * 2 spaces in editorconfig. * Create .travis.yml (#11) * Create .travis.yml * Update .travis.yml * Update .travis.yml * Update .travis.yml * Update .travis.yml * Move to Jest Expect (#6) * Initial jest conversion * Remove macho setup and remove jsdom package. * PromiseMiddleware test refactor. * Refactor ReduxTaxi tests to jest expect * Refactor ReduxTaxiMiddleware test to jest expect * Refactor ReduxTaxiProvider to jest expect * Refactor RegisterAsyncActions test to jest expect * Remove chai package * Remove trailing commas * Add Prettier * Add Prettier * Update list-staged file catch * Run Prettier on all JS files * Remove sinon in favor for jest mocks. * removing prettier deps from this PR. * remove trailing comma * Initial jest conversion * Remove macho setup and remove jsdom package. * Remove chai package * Remove trailing commas * Add Prettier * Add Prettier * Update list-staged file catch * Run Prettier on all JS files * Remove sinon in favor for jest mocks. * removing prettier deps from this PR. * packages. * Prettier pre-hook and reformat current files. * 2 spaces in editorconfig.
This PR removes
chai
package which was primarily using theassert
style tests in favour of using standardjest
except
assertions.All tests are passing as they were before, in the process of converting I refactored the tests to read a bit better. There were a few tests in
PromiseMiddleware.test.js
that were throwingunhandled promise rejection
warnings, these have all been resolved through the reorganization of the tests.I opted to use
sinon.spy
's to assist in the readability of the tests.This will complete #3
Closes #3