Configuring e2e tests with NextJS + Tescafe

I have a server-side rendered React app using Next JS and I'm trying to setup end-to-end tests with TestCafe. But when I try to run my tests I get the following error:

   1) A JavaScript error occurred on 

(...)

      Repeat test actions in the browser and check the console for errors.
      If you see this error, it means that the tested website caused it. You can fix it or disable
      tracking JavaScript errors in TestCafe. To do the latter, enable the "--skip-js-errors" option.
      If this error does not occur, please write a new issue at:
      "https://github.com/DevExpress/testcafe/issues/new?template=bug-report.md".
      
      JavaScript error details:
      Uncaught ReferenceError: window is not defined
          No stack trace available

Apparently the test scripts are being executed at server side, so naturally the window object doesn't exist.

Does anyone know how to fix it?