title: Test browser code with Intern through Grunt and Phantomjs
body: <p>I have been playing with Intern and made my tests work in the browser. To better integrate with my current workflow I'm trying to run my tests through grunt with phantomjs. However all my attempts have failed. I've been looking at this question as a reference <a href="https://stackoverflow.com/questions/16721654/intern-webdriver-and-phantomjs">Intern WebDriver and PhantomJS</a> but can't figure out all of the steps to make it work.</p>
  
  <p>First of all: Is it even possible to run the tests through grunt and phantomjs? </p>
  
  <p>A little bit of info:</p>
  
  <ul>
  <li>I don't want/can't connect to Sauce Labs or a Selenium testing environment.</li>
  <li>I want to test browser code while having jQuery as a shimmed dependency</li>
  <li>I have Grunt 0.4.1 and phantomjs 1.9.1 installed</li>
  <li>I'm not testing any ajax request (as the linked question is having problem with)</li>
  <li>I'm not familiar with neither Selenium nor Sauce Lab</li>
  </ul>
  
  <p>If it is possible to test through grunt and phanomjs, how would I go about doing it?</p>
  
  <p>I guess that I have to start the GhostDriver</p>
  
  <pre><code>phantomjs --webdriver=8910
  </code></pre>
  
  <p>But then what are the important pieces of info in the Intern config to make this work?</p>
  
  <pre><code>define({
    proxyPort: 9000,
    proxyUrl: 'http://localhost:9000/',
    environments: [
      {
        browserName: 'phantom',
        version: '1.9.0',
        platform: 'Linux'
      }
    ],
    webdriver: {
      host: 'localhost',
      port: 8910
    },
    maxConcurrency: 3,
    useSauceConnect: false,
    // ...
  });
  </code></pre>
  
  <p>How does the environments browserName map to phantomjs? I've tried the browserNames 'phantom' as well as 'phanomjs' with different versions and platforms (running Mac 10.7)</p>
  
  <p>My Gruntfile section for intern looks like:</p>
  
  <pre><code>intern: {
      phantom: {
          options: {
              config: 'tests/intern',
              reporters: ['webdriver']
          }
      }
  }
  </code></pre>
  
  <p>Running this setup without any test-suite that includes browser code outputs
  '<code>ReferenceError: document is not defined</code>' in '<code>node_modules/intern/lib/reporters/webdriver.js:41:19</code>'</p>
  
  <p>Adding browser tests gives '<code>ReferenceError: window is not defined</code>' in '<code>src/vendor/jquery/jquery-1.9.1.js:9597:5</code>'</p>
  
  <p>Running it through node gives the same '<code>window is not defined</code>' error.</p>
  
  <p><code>node node_modules/intern/client.js config=tests/intern</code></p>
  
  <p>What am I doing wrong/missing here?</p>