Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Angular 2] | ZoneJS not working #1513

kuashe opened this issue Jun 3, 2016 · 4 comments


Copy link

commented Jun 3, 2016

Using this HTML page

    <title>Angular 2 QuickStart</title>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- 3. Display the application -->

    <script src=""></script>
    <button id='foo' >Click me ! </button>


And this code

var fs = require("fs")
var jsdom = require("jsdom");
var doc = jsdom.jsdom( fs.readFileSync("index.html") , {
    virtualConsole: jsdom.createVirtualConsole().sendTo(console),

    features: {
      FetchExternalResources : ["script"],
       ProcessExternalResources: ["script"]

I have the following error

Error: Uncaught [TypeError: Cannot set property onreadystatechange of [object Object] which has only a getter]


This comment has been minimized.

Copy link

commented Feb 8, 2017

Understand why this would be tough, but would love the option to skip the browser in Angular 2+ tests, just as I do in React.


This comment has been minimized.

Copy link

commented Apr 4, 2017

jsdom must run in a function wrapped Zone.js context. I had the same problem when I was working on using Jest in Angular and it's already solved problem. IMO It has nothing to do with jsdom and this should be closed.

@kuashe If you're curious, here's a jest-preset-angular which enables you to test Angular apps in jsdom. What's better, it's several times faster than Karma with Chrome.


This comment has been minimized.

Copy link

commented Apr 6, 2017

Confirmed jsdom working with zone.js using jest-preset-angular. Doesn't look like a jsdom issue.


This comment has been minimized.

Copy link

commented Apr 6, 2017

Please take a look at my PR #1610. I know it was not good enough to be merged. But the diff points what is wrong between zone and jsdom. I'm running integration tests on Angular 2 with pure jsdom and this patch for some times now.

@kuashe kuashe closed this Jun 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
6 participants
You can’t perform that action at this time.