-
Notifications
You must be signed in to change notification settings - Fork 619
Add random source modules for node, browsers, and cross-platform usage #19
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
Conversation
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.
Looks good! It might be too soon, but we'll probably want a browser
field in the universal version of the app that sets the node version of the module to false
so bundlers don't attempt to pollyfill those node modules.
|
||
describe('implementation selection', () => { | ||
it('should use the node implementation in node', async () => { | ||
(isNode as any).mockReturnValue(true); |
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 looks like mockReturnValue
may be deprecated
https://facebook.github.io/jest/docs/mock-function-api.html#mockfnmockreturnvaluevalue
That said, I'm not convinced by the docs that their suggested alternative is what we want. mockImplementation
might work... I'm also fine with sticking to a major version of jest if this method gets removed.
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 mockImplementation
would be the way to go. I think we should keep updating jest until everything goes GA, so I'm willing to remove uses of deprecated functions until then.
Per our discussion re: |
#19) * Add random source modules for node, browsers, and cross-platform usage * Use util-locate-window instead of directly dereferencing "self"
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
This PR adds support for getting cryptographically secure random values (necessary for v4 UUIDs and any future encryption modules) from the WebCrypto APIs in supported browsers (including IE 11), from the
crypto
module in node, and from the SJCL everywhere else.