Search code examples
javascriptnode.jsjestjsauth0

Mock secure origin for auth0-spa-js in Jest tests


Trying to setup jest tests around auth0-spa-js but getting error 'auth0-spa-js must run on a secure origin' when attempting to await createAuth0Client(config). Whats the best way to mock secure origin in jest tests?


Solution

  • Mocking the module worked great for me.

    jest.mock('@auth0/auth0-spa-js');