Next.js: Cannot read property 'pageLoader' of null

Created on 18 Apr 2020  路  10Comments  路  Source: vercel/next.js

Bug report

Hey guys, I saw this issue #9951 being resolved, but I am having the same error with react-testing library

Describe the bug

I am trying to test a component, but have "Cannot read property 'pageLoader' of null" all over my tests (actually as many of them as many Links I have on a tested page)

I am using NextJs with Redux example and test it with react-testing-library.

the error:

[Error: Uncaught [TypeError: Cannot read property 'pageLoader' of null]
at reportException (/Users/vladislavsorokin/webprojects/rqc/node_modules/jsdom/lib/jsdom/living/helpers/runtime-script-errors.js:62:24)
at innerInvokeEventListeners (/Users/vladislavsorokin/webprojects/rqc/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:332:9)
at invokeEventListeners (/Users/vladislavsorokin/webprojects/rqc/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:267:3)
at HTMLUnknownElementImpl._dispatch (/Users/vladislavsorokin/webprojects/rqc/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:214:9)
at HTMLUnknownElementImpl.dispatchEvent (/Users/vladislavsorokin/webprojects/rqc/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17)
at HTMLUnknownElement.dispatchEvent (/Users/vladislavsorokin/webprojects/rqc/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:144:23)
at Object.invokeGuardedCallbackDev (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:385:16)
at invokeGuardedCallback (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:440:31)
at commitRootImpl (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:25082:9)
at unstable_runWithPriority (/Users/vladislavsorokin/webprojects/rqc/node_modules/scheduler/cjs/scheduler.development.js:697:12) TypeError: Cannot read property 'pageLoader' of null
at Link.handleRef (/Users/vladislavsorokin/webprojects/rqc/node_modules/next/dist/client/link.js:8:710)
at ref (/Users/vladislavsorokin/webprojects/rqc/node_modules/next/dist/client/link.js:13:67)
at commitAttachRef (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:22310:7)
at commitLayoutEffects (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:25349:7)
at HTMLUnknownElement.callCallback (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:336:14)
at innerInvokeEventListeners (/Users/vladislavsorokin/webprojects/rqc/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:316:27)
at invokeEventListeners (/Users/vladislavsorokin/webprojects/rqc/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:267:3)
at HTMLUnknownElementImpl._dispatch (/Users/vladislavsorokin/webprojects/rqc/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:214:9)
at HTMLUnknownElementImpl.dispatchEvent (/Users/vladislavsorokin/webprojects/rqc/node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:87:17)
at HTMLUnknownElement.dispatchEvent (/Users/vladislavsorokin/webprojects/rqc/node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:144:23)
at Object.invokeGuardedCallbackDev (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:385:16)
at invokeGuardedCallback (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:440:31)
at commitRootImpl (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:25082:9)
at unstable_runWithPriority (/Users/vladislavsorokin/webprojects/rqc/node_modules/scheduler/cjs/scheduler.development.js:697:12)
at runWithPriority$2 (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:12149:10)
at commitRoot (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:24922:3)
at finishSyncRender (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:24329:3)

at performSyncWorkOnRoot (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:24307:9)
at scheduleUpdateOnFiber (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:23698:7)
at updateContainer (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:27103:3)
at /Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:27528:7
at unbatchedUpdates (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:24433:12)
at legacyRenderSubtreeIntoContainer (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:27527:5)
at Object.render (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:27608:10)
at /Users/vladislavsorokin/webprojects/rqc/node_modules/@testing-library/react/dist/pure.js:86:25
at batchedUpdates$1 (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom.development.js:24386:12)
at act (/Users/vladislavsorokin/webprojects/rqc/node_modules/react-dom/cjs/react-dom-test-utils.development.js:1092:14)
at render (/Users/vladislavsorokin/webprojects/rqc/node_modules/@testing-library/react/dist/pure.js:82:26)
at render (/Users/vladislavsorokin/webprojects/rqc/utils/test-utils.js:28:10)
at Object.<anonymous> (/Users/vladislavsorokin/webprojects/rqc/__tests__/index.test.js:12:25)
at Object.asyncJestTest (/Users/vladislavsorokin/webprojects/rqc/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:100:37)
at /Users/vladislavsorokin/webprojects/rqc/node_modules/jest-jasmine2/build/queueRunner.js:45:12
at new Promise (<anonymous>)
at mapper (/Users/vladislavsorokin/webprojects/rqc/node_modules/jest-jasmine2/build/queueRunner.js:28:19)
at /Users/vladislavsorokin/webprojects/rqc/node_modules/jest-jasmine2/build/queueRunner.js:75:41
at processTicksAndRejections (internal/process/task_queues.js:85:5)

System information

  • OS:macOS 10.14.6
  • Version of Next.js: 9.3.5
  • Version of Node.js: 12.6.0
good first issue

All 10 comments

@timneutkens Can I work on it?

Sure!

@sorokinvj Could provide some snippet to reproduce? I could not to reproduce it.

@sorokinvj Could provide some snippet to reproduce? I could not to reproduce it.

@doniyor2109 I will do a snippet in a weekends, sorry can't make sooner than that. I mean I could open the whole project for access on github, but I am afraid this a lot of files!

@doniyor2109 this is the repo https://github.com/sorokinvj/rqc-next-tests, basically its just three news cards that fetched from prismic.io (cms) and showed in ui

@sorokinvj It seems the project has old version of Next. I upgraded to latest and it is working for me.
Here are changes https://github.com/sorokinvj/rqc-next-tests/pull/3

@doniyor2109 worked, thanks! Strangely, why 'latest' in package.json didn't work?

@sorokinvj yarn upgrade worked for me.

Can this issue be closed?

@timneutkens sorry, forgot. Yes, thanks for the support!

Was this page helpful?
0 / 5 - 0 ratings