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

Error running jest test #251

Closed
kurund opened this issue Aug 24, 2022 · 7 comments
Closed

Error running jest test #251

kurund opened this issue Aug 24, 2022 · 7 comments

Comments

@kurund
Copy link

kurund commented Aug 24, 2022

Hello,

I am getting the following error while running the test suite. UI works fine without any issues.

  ● Test suite failed to run

    Cookie has domain set to the public suffix "localhost" which is a special use domain. To allow this, configure your CookieJar with {allowSpecialUseDomain:true, rejectPublicSuffixes: false}.

      at Object.getPublicSuffix (node_modules/tough-cookie/lib/pubsuffix-psl.js:62:11)
      at permuteDomain (node_modules/tough-cookie/lib/permuteDomain.js:38:28)
      at MemoryCookieStore.findCookies (node_modules/tough-cookie/lib/memstore.js:99:21)
      at MemoryCookieStore.findCookies (node_modules/tough-cookie/node_modules/universalify/index.js:5:67)
      at CookieJar.getCookies (node_modules/tough-cookie/lib/cookie.js:1410:11)
      at CookieJar.getCookies (node_modules/tough-cookie/node_modules/universalify/index.js:5:67)
      at CookieJar.getCookieString (node_modules/tough-cookie/lib/cookie.js:1455:21)
      at CookieJar.getCookieString (node_modules/tough-cookie/node_modules/universalify/index.js:5:67)
      at CookieJar.getCookieStringSync (node_modules/tough-cookie/lib/cookie.js:1726:17)
      at DocumentImpl.get cookie [as cookie] (node_modules/jsdom/lib/jsdom/living/nodes/Document-impl.js:860:28)

Any thoughts how to fix this?

@Tdirmeikis
Copy link

Tdirmeikis commented Aug 25, 2022

As a workaround you could try to add custom testURL property to jest configuration.

Example using jest configuration in package.json
"jest": { "testURL": "https://jestjs.io" }

@kurund
Copy link
Author

kurund commented Aug 25, 2022

Example using jest configuration in package.json
"jest": { "testURL": "https://jestjs.io" }

Thank you. This fixes the test failure.

@Norfeldt
Copy link

Norfeldt commented Aug 25, 2022

I tried without any luck (jest 27)

/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
  preset: 'jest-expo',
  rootDir: '../../',
  testURL: 'http://localhost:3001',
  setupFilesAfterEnv: ['./test/jest/setup.js'], 

(also tried using https://jestjs.io just in case that does some 🪄)

Cookie has domain set to the public suffix "localhost" which is a special use domain. To allow this, configure your CookieJar with {allowSpecialUseDomain:true, rejectPublicSuffixes: false}.

      at Object.getPublicSuffix (node_modules/tough-cookie/lib/pubsuffix-psl.js:62:11)
      at permuteDomain (node_modules/tough-cookie/lib/permuteDomain.js:38:28)

@sanderboon
Copy link

testEnvironmentOptions: { url: "https://jestjs.io", },

worked for me (jest 29)

@awaterma
Copy link
Member

Please try with our latest release, we have updated our treatment of single word domains for localhost and invalid per RFC 6761: https://www.rfc-editor.org/rfc/rfc6761.html

@awaterma
Copy link
Member

This should be fixed in 4.1.2. Please let us know if you see any more issues.

@kurund
Copy link
Author

kurund commented Aug 27, 2022

Thank you. I can confirm that it's fixed for me.

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

5 participants