-
-
Notifications
You must be signed in to change notification settings - Fork 208
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
Add with-mocha example #51
Conversation
I left this pretty close to the example issue and solution. I think this is general enough to show as an example for |
75cc1f1
to
ae871a9
Compare
|
||
// Support fetch in a node env. Requires the localstorage polyfill | ||
require('isomorphic-fetch') | ||
require('localstorage-polyfill') |
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.
Do we need the localstorage-polyfill
if we use whatwg-fetch
instead?
I find it the less things our examples have, the more straightforward they are to follow.
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.
@kettanaito localstorage would still need to be mocked or polyfilled here using whatwg-fetch. I can just include a mock if you think it's more transparent than including this polyfill or a mock lib, just let me know :)
afterEach(() => { | ||
// Reset any modified handlers and cleanup tests | ||
server.resetHandlers() | ||
cleanup() |
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.
Doesn't RTL call cleanup
automatically? Does that work only in Jest?
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.
It should, but unfortunately, that's not the case here. If you add console.log(screen.debug())
to the last test in Child
, you'll see that it stacks components and the tests will fail.
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.
Thanks for preparing this example, @msutkowski! I've left a few comments.
…rifying comments in setup
@kettanaito Updated, but left the localstorage polyfill in place per the comment. If you want me to include a manual mock for this, just let me know :) |
Thanks for all the work on this, @msutkowski! As I'm updating the examples, I think I will drop this one. The usage with mocha is rather straightforward, and mocha+react is a bit too complex to feature as a standalone example. |
Changes
Example checklist
npm test
.README.md
file to the root directory of my example.