-
Notifications
You must be signed in to change notification settings - Fork 198
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
Write UT for cryptoUtils module #287
Comments
Hey, @muke1908. Would like to work on these tests as well! Might take me a bit longer though. Let me know if thats ok with you. |
@estefysc sure, go ahead! |
@muke1908 perfect! I will. Thanks. |
Hey @muke1908 just wanted to double check.. are the tests just for "cryptoUtils", meaning the functions generateKeypairs, encryptMessage, and decryptMessage? Or should I include tests for all the other functions in the file? |
@estefysc Yes those three are enough as only they are exported. |
@muke1908 ok, perfect. Thanks for your response. Will finish soon for you to review and make suggestions. |
@muke1908 I am having issues mocking the window.crypto.subtle dependency. I have done some research, and I have found info that talks about using the node crypto.webcrypto property like so:
Would this be ok? |
@estefysc You should not use the external module for testing. It needs to be mocked.
also, you need to add mockReturnvalue to each func. For example, for generateKey:
it should work |
@muke1908 Perfect. Thanks for the explanation. Will work in it. |
@muke1908 I tried your suggestion and a couple versions of it, but I am seeing the following error in all cases:
|
can You push your code and create a PR, I’ll check
…On Sat 17. Jun 2023 at 23:28, estefysc ***@***.***> wrote:
@muke1908 <https://github.com/muke1908> I tried your suggestion and a
couple versions of it, but I am seeing the following error in all cases:
The error below may be caused by using the wrong test environment, see https://jestjs.io/docs/configuration#testenvironment-string.
Consider using the "jsdom" test environment.
ReferenceError: window is not defined
—
Reply to this email directly, view it on GitHub
<#287 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AE23SBLI2HHDUBQYAMN4OG3XLYOPZANCNFSM6AAAAAAX2D7QEY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Ok, just did. |
* initiated work - started template * added some tests * changed the mock implementation * testing code * fix: added jest config, added mock * working on mocks * working on mocks and encryptMessage tests * Tests finished * Update service/src/crypto.test.ts --------- Co-authored-by: Estefania Sanchez <estefaniasanchez@Estefanias-Work-MacBook-Air.local> Co-authored-by: Mukesh <mukeshbiswas@microsoft.com> Co-authored-by: Estefania SanchezCabrejos <esanchezcabrejos@ncf.edu> Co-authored-by: Mukesh <mukeshbsws@gmail.com>
Write unit test for cryptoUtils module, mock all necessary external browser dependency.
https://github.com/muke1908/chat-e2ee/blob/master/service/src/crypto.ts
The text was updated successfully, but these errors were encountered: