michelonsouza / encrypt-storage

EncryptStorage provide a little more security in frontend
MIT License
266 stars 13 forks source link

Mocking localStorage when Unit Testing Modules using Pinia/Encrypt-Storage #590

Closed jhuerta closed 1 year ago

jhuerta commented 1 year ago

Hi,

We are using Vue 3 and Pinia with Encrypt-Storage.

We are implementing some unit tests in Vue and we need to mock the localStorage behind Encrypt-Storage/Pinia.

As we are using Vitest, it seems the way to is using the following package vitest-localstorage-mock.

My questions are: Do you suggest any other way to implement the unit tests of the modules using Pinia/Encrypt-Storage ? Any code example?

Thanks,

Juan

michelonsouza commented 1 year ago

Hi @jhuerta, hope you are doing well. To be honest, I haven't used encrypt-storage with vitest yet. I believe that you are performing tests of the encryption itself. Third-party package testing, just in case. I would mock encrypt-storage and use a bypass. Mocking the value itself, or just encrypting with EncryptStorage.encryptValue and comparing the values.

I'm sorry for not answering earlier and if I didn't answer your question properly. I'm pretty busy at work.

But I'm here and available.

Thanks.

jhuerta commented 1 year ago

Hi Michel,

Thanks a lot for the information.

Cheers,

Juan

On Mon, 6 Feb 2023 at 18:25, Michelon Souza @.***> wrote:

Hi @jhuerta https://github.com/jhuerta, hope you are doing well. To be honest, I haven't used encrypt-storage with vitest yet. I believe that you are performing tests of the encryption itself. Third-party package testing, just in case. I would mock encrypt-storage and use a bypass. Mocking the value itself, or just encrypting with EncryptStorage.encryptValue and comparing the values.

I'm sorry for not answering earlier and if I didn't answer your question properly. I'm pretty busy at work.

But I'm here and available.

Thanks.

— Reply to this email directly, view it on GitHub https://github.com/michelonsouza/encrypt-storage/issues/590#issuecomment-1419453593, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJUJJPIVLTMB3XF3BYI3XDWWEXXVANCNFSM6AAAAAAUQAYC4Q . You are receiving this because you were mentioned.Message ID: @.***>