Category: AngularJS

Apr 9 2013

CFML unit test runner for AngularJS

I am working my way through the AngularJS tutorials again, this time paying more attention to the testing side of AngularJS.

In the test suites, there is a runner for End 2 End testing, but not the unit test. To run those the tutorial links off to how to install node.js and Karma (formally testacular). This is extremely cool for the Continuous Intergration side of things, but I am not quite there yet.

So I have created myself a unit test runner with CFML. I am only up to step 5, so may add more to this as I work my way through the rest of the tutorial. You will need to download Jasmine. Drop this code in test/unit/runner.cfm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  <title>Jasmine Spec Unit Runner</title>

  <link rel="shortcut icon" type="image/png" href="/jasmine/images/jasmine_favicon.png">
  <link rel="stylesheet" type="text/css" href="/jasmine/lib/jasmine-1.3.1/jasmine.css">
  <script type="text/javascript" src="/jasmine/lib/jasmine-1.3.1/jasmine.js"></script>
  <script type="text/javascript" src="/jasmine/lib/jasmine-1.3.1/jasmine-html.js"></script>

  <!-- AngularJS files -->
  <script src="/lib/angular-1.0.5/angular.js" ></script>
  <script src="/lib/angular-1.0.5/angular-mocks.js" ></script>

  <!-- include source files here... -->
  <cfdirectory directory="../../app/js/" action="list" filter="*.js" name="qryJS" >
  <cfoutput query="qryJS">
  <script type="text/javascript" src="../../app/js/"></script>

  <!-- include spec files here... -->
  <cfdirectory directory="." action="list" filter="*.js" name="qrySpecs" >
  <cfoutput query="qrySpecs">
  <script type="text/javascript" src=""></script>

  <script type="text/javascript">
    (function() {
      var jasmineEnv = jasmine.getEnv();
      jasmineEnv.updateInterval = 1000;

      var htmlReporter = new jasmine.HtmlReporter();


      jasmineEnv.specFilter = function(spec) {
        return htmlReporter.specFilter(spec);

      var currentWindowOnload = window.onload;

      window.onload = function() {
        if (currentWindowOnload) {

      function execJasmine() {




Posted by AJ Mercer at 3:02 pm - Categories: AngularJS | CFML | ColdFusion | Railo