benawad / graphql-ts-server-boilerplate

A GraphQL server boilerplate made with Typescript, PostgreSQL, and Redis
693 stars 181 forks source link

localStorage is not available for opaque origins #10

Open hemedani opened 6 years ago

hemedani commented 6 years ago

I have this error when running yarn test

 FAIL  src/modules/user/logout/logout.test.ts
  ● Test suite failed to run

    SecurityError: localStorage is not available for opaque origins

      at Window.get localStorage [as localStorage] (../../node_modules/jsdom/lib/jsdom/browser/Window.js:257:15)
          at Array.forEach (<anonymous>)

 FAIL  src/modules/user/forgotPassword/forgotPassword.test.ts
  ● Test suite failed to run

    SecurityError: localStorage is not available for opaque origins

      at Window.get localStorage [as localStorage] (../../node_modules/jsdom/lib/jsdom/browser/Window.js:257:15)
          at Array.forEach (<anonymous>)

 FAIL  src/modules/user/register/createConfirmEmailLink.test.ts
  ● Test suite failed to run

    SecurityError: localStorage is not available for opaque origins

      at Window.get localStorage [as localStorage] (../../node_modules/jsdom/lib/jsdom/browser/Window.js:257:15)
          at Array.forEach (<anonymous>)

 FAIL  src/modules/user/register/register.test.ts
  ● Test suite failed to run

    SecurityError: localStorage is not available for opaque origins

      at Window.get localStorage [as localStorage] (../../node_modules/jsdom/lib/jsdom/browser/Window.js:257:15)
          at Array.forEach (<anonymous>)

 FAIL  src/routes/confirmEmail.test.ts
  ● Test suite failed to run

    SecurityError: localStorage is not available for opaque origins

      at Window.get localStorage [as localStorage] (../../node_modules/jsdom/lib/jsdom/browser/Window.js:257:15)
          at Array.forEach (<anonymous>)

 FAIL  src/modules/user/me/me.test.ts
  ● Test suite failed to run

    SecurityError: localStorage is not available for opaque origins

      at Window.get localStorage [as localStorage] (../../node_modules/jsdom/lib/jsdom/browser/Window.js:257:15)
          at Array.forEach (<anonymous>)

 FAIL  src/modules/user/login/login.test.ts
  ● Test suite failed to run

    SecurityError: localStorage is not available for opaque origins

      at Window.get localStorage [as localStorage] (../../node_modules/jsdom/lib/jsdom/browser/Window.js:257:15)
          at Array.forEach (<anonymous>)
benawad commented 6 years ago

does yarn start work for you?

philkeys commented 6 years ago

@hemedani

what worked for me, was within the jest config in package.json I added:

"testEnvironment": "node"

hemedani commented 6 years ago

yah yarn start is working

philkeys commented 6 years ago

@hemedani Hey, I wanted to let you know that I ended up switching from "testEnvironment": "node" to "testURL": "http://localhost/" later in the videos because the node setting was causing issues with the session testing in Jest—which is around video 16 or 17.

hemedani commented 6 years ago

Tanks @philkeys works like a charm