Oidc-client issues with jest

Hi @bigopon , I am trying to write unit test case for my component. It has a dependency of a custom-service and that custom service uses oidc-client to authenticate user. It keeps throwing me error…

sessionStorage is not defined

I am not using any session storage, I am using oidc-client.

Please assist.

1 Like

You should typically try to mock away the sessionstorage, which might be used by your dependency https://stackoverflow.com/questions/40967727/jest-testing-sessionstorage-undefined

Instead of doing it manually as described above here is another way to do it with jest https://www.npmjs.com/package/jest-localstorage-mock