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?
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?
After digging into auth0 code to see what it wants, i gave it global.crypto.subtle = {} and it seems to have satisfied it, the error has gone, the tests pass:
const JSDOM = require('jsdom').JSDOM
Object.defineProperty(global.self, 'crypto', {
value: {
getRandomValues: arr => crypto.randomBytes(arr.length)
}
})
global.crypto.subtle = {} // this gets around the 'auth0-spa-js must run on a secure origin' error