title: Zombiejs jQuery nullTypeError 'compareDocumentPosition'
body: <p>Zombie: Cannot read property 'compareDocumentPosition' of null TypeError: Cannot read property 'compareDocumentPosition'
   of null</p>
  
  <p>This happens any time I try to load a page that includes jQuery using Zombiejs.  This has happened to me on Debian &amp; Windows, with a variety of different pages, using different versions of jQuery and with nothing else on the page.</p>
  
  <p>It seems to have something to do with the way jsDom evaluates jQuery before the page document is ready, but it's pretty far over my head.</p>
  
  <p>Anyone run into this, know a workaround, or have any pointers? Thanks!</p>
  
  <p><strong>UPDATE:</strong> This is my test (which actually passes, but running with debug shows the error I mentioned):</p>
  
  <pre><code>zombie = require "zombie"
  browser = new zombie.Browser({debug: false})
  $ = require "jquery"
  require "should"    
  
  app = "http://localhost:3000/"
  
  describe "app", -&gt;
    describe "index", -&gt;
      it "should display correct title", (done) -&gt;
        browser.visit app, (err, browser) -&gt;
          done()
  </code></pre>
  
  <p>And this is the error:</p>
  
  <pre><code>Zombie: GET http://localhost:3000/js/jquery-1.7.1.js =&gt; 200 Zombie: Cannot read property 'compareDocumentPosition' of null TypeError: Cannot read property 'compareDocumentPosition' of null
      at Object.&lt;anonymous&gt; (/js/jquery-1.7.1.js:4807:30)
      at Object.&lt;anonymous&gt; (/js/jquery-1.7.1.js:5301:2)
      at Object.&lt;anonymous&gt; (/js/jquery-1.7.1.js:9266:2)
      at Object._evaluate (/home/dev/Hg/rpg-chat-bdd/node_modules/zombie/lib/zombie/browser.js:136:28)
      in /js/jquery-1.7.1.js
  </code></pre>
  
  <p>which causes a other errors because '$' is not defined in the rest of my scripts.</p>
  
  <p>This is the HTML of the page I'm testing:</p>
  
  <pre><code>&lt;title&gt;Welcome to Test!&lt;/title&gt;
  
  &lt;body&gt;
    &lt;div id="main"&gt;
    &lt;/div&gt;
  
    &lt;script type="text/javascript" src="/js/jquery-1.7.1.js"&gt;&lt;/script&gt;
    &lt;script type="text/javascript" src="/js/application.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  </code></pre>