01/11/2023, 8:20 PM
Hey team, Do you have any tests for components that compose
? I'm wanting to add some automated tests for our 2fa flow in the webapp. We're mocking the SessionContext but get an error in the component.
The error looks like it's coming from a dependency used by supertokens (tough-cookie) and apparently has some history in that project. Curious if you all run into that when testing. link to their github issue if you're curious: https://githubcom/salesforce/tough-cookie/issues/215


01/12/2023, 5:06 AM
Hey. @porcellus can help with this.


01/12/2023, 8:03 AM
As far as I can see supertokens doesn't use tough-cookie. It's used by jsdom and request (and maybe some others) which are a dev dependencies of our library. Since they are only dev dependencies they shouldn't install for you when you install supertokens in your project. Anyway, we haven't come up on this issue, we do most of our testing (of auth-react) in browser through puppeteer.
You could try setting up your jsdom environment with a different URL (we use "" in some tests)
You could also try adding a custom
into the supertokens config. Using that you should be able to fully customize how we handle cookies, you could even make it use localstorage or some kind of in-memory thing completely circumventing tough-cookies
I can't find a guide about this in our docs, but: this is a function that should return an object with two props: - getCookie: by default this returns
(basically a string of the format
cookieName1=value; cookie_name2=value...
) - setCookie: by default this takes a string parameter and assigns it to
. (this saves it into the cookie list, the format of the string is something like
cookiename=value; cookieSettings...