Instead of trying to recreate Specrunner via Chutzpah on a build server, which is hard for me to configure and work. The goal was to get karma to output current tests in the trx test format that TFS recognizes and then publish to the assembly. Please note that I use PhantomJs to run my tests through Karma, but I will not describe it here, since it is well lit elsewhere.
1) install the karma-trx-reporter plugin via npm in your web project (or a similar plugin)
2) Configure Karma.config to enable trx reporter
reporters: ['dots', 'trx'], trxReporter: { outputFile: 'test-results.trx' }, // notify karma of the available plugins plugins: [ 'karma-jasmine', 'karma-phantomjs-launcher', 'karma-trx-reporter', ],
3) Create a Gulp (or grunt) task to run karma tests if you donβt already have it. Run the task locally and make sure that it creates the test-results.trx above. (It doesn't matter where the file is created on the build server):
gulp.task('test', function () { return gulp.src(['tests/*.js']).pipe(karma({ configFile: __dirname + '/Testing/karma.config.js', singleRun: true })); });
4) Add the GFS (or Grunt) TFS build task to run the karma tests created in the previous step and output the trx file. 
5) Add the GFS (or Grunt) TFS build task to publish the test results and merge them into a build. Note that the "Test Result Files" path is a wild card ** / *. Trx to find any trx files in the build path (i.e., find our previously created file). The "Results Merge Results" is checked to merge both Jasmine test runs and our C # test in the same session. "Continue on error" is not brushed aside to ensure that any failures of the jasmine test will break the assembly.

You will see two sets of tests that were run and included as part of the assembly!

source share