maenu / grunt-template-jasmine-istanbul-example

Example application using grunt-istanbul and grunt-contrib-jasmine
MIT License
21 stars 8 forks source link

Creating a valid html runner to run in a browser #5

Closed wheresrhys closed 2 months ago

wheresrhys commented 11 years ago

I've been playing around with getting the task to also create a specRunner page that won't throw an error in the browser. I came up with the following task, to be run after your tests (and of course with keepRunner: true)

  grunt.registerTask('cleanRunner', function () {
    var done = this.async();
    var fs = require('fs');
    fs.readFile('specRunner.html', 'utf8', function (err, data) {
      if (err) throw err;
      fs.writeFile('specRunner.html', data.replace('url = \'./.grunt/grunt-contrib-jasmine/\' + url;', '').replace('\'.grunt/grunt-contrib-jasmine/grunt-template-jasmine-istanbul/reporter.js\',\'./.grunt/grunt-contrib-jasmine/reporter.js\'', ''), function (err) {
        if (err) throw err;
      });
    });    
  });

It's a bit messy at the moment but if you're open to the idea of adding it to the demo I'll tidy it up and create a pull request.