Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CookieJar - Tough-Cookie breaking change #3419

Closed
arpowers opened this issue Aug 22, 2022 · 8 comments
Closed

CookieJar - Tough-Cookie breaking change #3419

arpowers opened this issue Aug 22, 2022 · 8 comments

Comments

@arpowers
Copy link

ToughCookie just released a breaking change in a minor release and it's breaking all related tests using JSDom (when in localhost context)

Cause salesforce/tough-cookie#246

Blown up tests look like this:
Screen Shot 2022-08-22 at 3 44 12 PM

Is it possible to provide the options required to the dependency?

Otherwise, recommend pinning this particular dependency to version 4.0 until you have a chance to update

@arpowers arpowers changed the title CookieJar breaking change CookieJar - Tough-Cookie breaking change Aug 22, 2022
@CSchulz
Copy link

CSchulz commented Aug 23, 2022

You can configure the cookie jar via the jsdom options, it is called cookieJar.

Here the example we are using for our jsdom jest environment:

testEnvironmentOptions: {
  url: 'http://localhost.local/',
  cookieJar: new jsdom.CookieJar(undefined, {
    allowSpecialUseDomain: true,
  }),
},

You have to use a FQDN even for localhost otherwise you will run into salesforce/tough-cookie#248 bug.

@arpowers
Copy link
Author

Only problem for us is that we are using Vitest which doesn't provide an interface (that I've seen)

@redbugz
Copy link

redbugz commented Aug 23, 2022

If tough-cookie is going to be picky about this now, it would seem that jsdom should configure their internal cookieJar to be loose and allow special domains by default, as that seems a common use case for testing is to use special use domains

@andreschort
Copy link

Hi, this had me spinning a few hours today.
If you are using npm v8 you can use the overrides in package.json (https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides)
Like this:
"overrides": { "tough-cookie": "4.0.0" },

@domenic
Copy link
Member

domenic commented Aug 24, 2022

I'm confident tough-cookie will revert their breaking change. I have no plans to address this on the jsdom side; please direct your attention to their repository instead, to urge them to fix their breaking change sooner.

@CSchulz
Copy link

CSchulz commented Aug 24, 2022

If anyone still has trouble with the new 4.1.1 release, check your used url for your testing environment. It needs to be a full qualified domain name in case of localhost you can use localhost.local

@nagakiran
Copy link

You can configure the cookie jar via the jsdom options, it is called cookieJar.

Here the example we are using for our jsdom jest environment:

testEnvironmentOptions: {
  url: 'http://localhost.local/',
  cookieJar: new jsdom.CookieJar(undefined, {
    allowSpecialUseDomain: true,
  }),
},

You have to use a FQDN even for localhost otherwise you will run into salesforce/tough-cookie#248 bug.

Have tried this config in "jsest.config.js" but getting the error "jsdom is not defined".
Do we need to import "jsdom" in some way to make it available in "jest.config.js" or this code snippet need to be placed in some other file?

@CSchulz
Copy link

CSchulz commented Aug 26, 2022

You can configure the cookie jar via the jsdom options, it is called cookieJar.
Here the example we are using for our jsdom jest environment:

testEnvironmentOptions: {
  url: 'http://localhost.local/',
  cookieJar: new jsdom.CookieJar(undefined, {
    allowSpecialUseDomain: true,
  }),
},

You have to use a FQDN even for localhost otherwise you will run into salesforce/tough-cookie#248 bug.

Have tried this config in "jsest.config.js" but getting the error "jsdom is not defined". Do we need to import "jsdom" in some way to make it available in "jest.config.js" or this code snippet need to be placed in some other file?

Yes you have to require jsdom, but this is not required any more. With 4.1.2 there is another patch release which handles this case as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants