Mocha 'Uncaught ReferenceError: window is not defined'

Viewed 8493

I'm just starting with JS unit testing and while every tests are going well (I've went with Mocha) I'm having a problem while it requires some 'document's' attributes, like:

var baseTag  = document.getElementsByTagName('base');

it gives me the following error:

Mocha 'Uncaught ReferenceError: document is not defined'

my test run command is:

mocha -u bdd test.js --reporter spec

now my question is, do I need some PhantomJS (or simillar tool) for testing when I need an acces for document's and DOM objects? Or I'm just opened for any advice how this should be resolved.

1 Answers
Related