Wednesday, February 19, 2014

Getting a Spec to run with Jasmine in the browser

This simple issue vexed me for an hour, I thought I'd save you all some time.

"I loaded the Jasmine SpecRunner.html file but the report says 0 specs run"  What gives?

Well, in my case, running with Chrome, it turned out to be simple....I had accidentally create my javascript 'script' tag as an empty tag, and that's all it was.  This was annoying in that no console error messages appeared, I just had to eyeball it.

So this bit


    <!-- include source files here... -->
  <script type="text/javascript" src="../../src/common/virtual-collections/virtualCollectionsService.js"></script>

  <!-- include spec files here... -->
  <script type="text/javascript" src="common/virtual-collections/virtualCollectionsServiceSpec.js"/>


Just had to become this bit...and wa-la!


 <!-- include source files here... -->
  <script type="text/javascript" src="../../src/common/virtual-collections/virtualCollectionsService.js"></script>

  <!-- include spec files here... -->
  <script type="text/javascript" src="common/virtual-collections/virtualCollectionsServiceSpec.js"></script>


The small things always kill you.  Jasmine was right, there were no specs.