Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Can't use zones with jsdom #708

@DaveMBush

Description

@DaveMBush

I'm trying to run jsdom to run my angular2 test with karma. JsDom tries to set onreadystatechange to null and fails. The problem exist because jsdom doesn't define onreadystatechange using defineProperty() but zones sets the property as readonly in property-descriptor.ts (line 73).

Adding a setter seems to fix the problem

  Object.defineProperty(XMLHttpRequest.prototype, 'onreadystatechange', {
    enumerable: true,
    configurable: true,
    get: function() {
      return this.orsc;
    },
    set: function(f) {
      this.orsc = f;
    }
  });
  const req = new XMLHttpRequest();
  req.onreadystatechange = function(){}
  const result = !!req.onreadystatechange;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions