happy-dom icon indicating copy to clipboard operation
happy-dom copied to clipboard

ReferenceError: XMLHttpRequest is not defined

Open sschneider-ihre-pvs opened this issue 3 years ago • 1 comments

I try to use happy-dom jest env in a quasar project and am facing this error when jest hits the line with

import { installQuasarPlugin } from '@quasar/quasar-app-extension-testing-unit-jest';

stack trace

      at Object.<anonymous> (node_modules/quasar/dist/quasar.esm.prod.js:6:22776)
      at Object.<anonymous> (node_modules/@quasar/quasar-app-extension-testing-unit-jest/src/helpers/install-quasar-plugin.ts:4:1)
      at Object.<anonymous> (node_modules/@quasar/quasar-app-extension-testing-unit-jest/src/helpers/index.ts:1:1)

My guess, this is not used but has a reference in the dist file.

sschneider-ihre-pvs avatar May 02 '22 08:05 sschneider-ihre-pvs

I have a similar problem with using the logrocket package.

ReferenceError: XMLHttpRequest is not defined
 ❯ new e evalmachine.<anonymous>:1:77916
 ❯ script.onload node_modules/.pnpm/[email protected]/node_modules/logrocket/dist/build.umd.js:3641:27
    3639|       // causing _LRlogger to be undefined.  Let's make sure its there first.
    3640|       if (typeof window._LRLogger === 'function') {
    3641|         instance.onLogger(new window._LRLogger({
       |                           ^
    3642|           sdkVersion: sdkVersion
    3643|         }));

Even though it doesn't get used, just importing the package tries to use XMLHttpRequest

MarkLyck avatar May 04 '22 15:05 MarkLyck

Thanks for reporting @sschneider-ihre-pvs! 🙂

We have now added support for XMLHttpRequest.

You can read more about the release here: https://github.com/capricorn86/happy-dom/releases/tag/v7.8.0

capricorn86 avatar Dec 07 '22 16:12 capricorn86

he hey, some xmas gifts come early :D

sschneider-ihre-pvs avatar Dec 07 '22 16:12 sschneider-ihre-pvs