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 Intern WebDriver and PhantomJS but can't figure out all of the steps to make it work.
First of all: Is it even possible to run the tests through grunt and phantomjs?
A little bit of info:
- I don't want/can't connect to Sauce Labs or a Selenium testing environment.
- I want to test browser code while having jQuery as a shimmed dependency
- I have Grunt 0.4.1 and phantomjs 1.9.1 installed
- I'm not testing any ajax request (as the linked question is having problem with)
- I'm not familiar with neither Selenium nor Sauce Lab
If it is possible to test through grunt and phanomjs, how would I go about doing it?
I guess that I have to start the GhostDriver
phantomjs --webdriver=8910
But then what are the important pieces of info in the Intern config to make this work?
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,
// ...
});
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)
My Gruntfile section for intern looks like:
intern: {
phantom: {
options: {
config: 'tests/intern',
reporters: ['webdriver']
}
}
}
Running this setup without any test-suite that includes browser code outputs
'ReferenceError: document is not defined
' in 'node_modules/intern/lib/reporters/webdriver.js:41:19
'
Adding browser tests gives 'ReferenceError: window is not defined
' in 'src/vendor/jquery/jquery-1.9.1.js:9597:5
'
Running it through node gives the same 'window is not defined
' error.
node node_modules/intern/client.js config=tests/intern
What am I doing wrong/missing here?