Referenceerror: Can't Find Variable X When Using Grunt Test In Yeoman
I'm using yeoman, grunt, mocha. I want to do BDD so I make basic unit test and run grunt test in console, which gives me ReferenceError: can't find variable: Creature opening test/
Solution 1:
This is probably because of this line. connect.static(config.app). Running it on the commandline, it runs connect, and sets the root/base path (where it reads the file) to app and test. So if you remove app it works for commandline, however if you are running it as a file, it is relative, hence needing 'app'
Solution 2:
probably you call
<script>mocha.run()</script>
when DOM is not ready yet try this
<script>if( document.readyState === "complete" ) {
var creature = newCreature('test');
alert(creature .name);
//mocha.run()
}
</script>
or with jQuery
$(function() {
var creature = newCreature('test');
alert(creature .name);
//mocha.run()
});
Solution 3:
Have you tried putting
<scriptsrc="../app/scripts/creature.js"></script>
before
<scriptsrc="bower_components/mocha/mocha.js"></script>
It looks like the var isn't defined and probably what volkinc was after with his response.
Post a Comment for "Referenceerror: Can't Find Variable X When Using Grunt Test In Yeoman"