execução de testes karma sem executar quaisquer testes

Estou a usar o karma com a jasmine e segui o guia online, instalando usando o

npm install --save-dev karma

e outras necessidades

eu corri

./node_modules/karma/bin/karma start

e

karma start karma.conf.js
Que abriu um navegador cromo externo mostrando que o karma está conectado. Escrevi um teste de unidade simples para uma das minhas funções. parece que não está a fazer nenhum teste. Este é o meu ficheiro de configuração do karma.

    // Karma configuration
module.exports = function(config) {
 config.set({
// base path, that will be used to resolve files and exclude
basePath: '',

// testing framework to use (jasmine/mocha/qunit/...)
frameworks: ['jasmine'],

// list of files / patterns to load in the browser
files: [
  'app/assets/components/angular/angular.js',
  'app/assets/components/angular-mocks/angular-mocks.js',
  'app/assets/javascripts/**/**/*.js',
  'spec/javascripts/**/*.js'
],

// list of files / patterns to exclude
exclude: [],

// web server port
port: 8080,

// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel: config.LOG_INFO,

// enable / disable watching file and executing tests whenever any file changes
autoWatch: false,

// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari (only Mac)
// - PhantomJS
// - IE (only Windows)
browsers: ['Chrome'],


// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false
});
 };

o meu teste de unidade

describe('Unit: AddMedicalService',function(){


beforeEach(module('DoctiblePreTreatment'));
var ctrl, scope;

beforeEach(inject(function($controller,$rootScope){
scope = $rootScope.$new();

ctrl = $controller('AddMedicalServiceModalCtrl',{
  $scope: scope
  });
}));


it('should create return true if var 1 is greater than var2 , false if other wise',
function(){
  var compare1 = function(){
    var var1 = 1;
    var var2 = 0;
    return var1 > var2;
  }

  var compare2 = function(){
    var var1 = 0;
    var var2 = 1;
    return var1 > var2;
  }

  expect(compare1).toBeTruthy();
  expect(compare2).toBeFalsy();

   });

  });

a função específica no controlador im a tentar para testar

(function() {
app.controller('AddMedicalServiceModalCtrl',['ProviderMedicalService','Treatment','$scope','$modalInstance',function(ProviderMedicalService,Treatment,$scope,$modalInstance){
    $scope.newTreatment = {}


    $scope.checkless = function(var1,var2){
        var1 = parseInt(var1);
        var2 = parseInt(var2);

        if(var1 > var2){
            return true;
        }
        else{
            return false;
        }
    }
    }]);
   })();
O que é mostrado na consola quando eu executar o karma?
  INFO [karma]: Karma v0.12.21 server started at http://localhost:8080/
  INFO [launcher]: Starting browser Chrome
  INFO [Chrome 36.0.1985 (Mac OS X 10.9.4)]: Connected on socket MkqZfXcO6iIX4Od23QEr with id 9498055
Informação adicional: estou a usar js angulares com ruby nos carris. Sei que há a jóia de jasmim lá fora que me pode ajudar. Mas o meu chefe insistiu que devíamos tentar usar o karma para fazer os testes de unidade/E2E para a porção anuglarjs e rspec para os carris.

Author: Jim, 2014-08-08

1 answers

Em karma.config.js, Definir singleRun ou autoWatch para true. No vosso caso, ambos estão definidos como falsos, por isso o karma não está a fazer os testes.

SingleRun: Se for verdadeiro, captura navegadores, executa testes e sai com 0 código de saída (se todos os testes tiverem passado) ou 1 código de saída (se algum teste tiver falhado).

singleRun: true

Verificar automaticamente: activar ou desactivar a observação de ficheiros e executar os testes sempre que um destes ficheiros mudar. Se quiseres ver os teus ficheiros.

autoWatch: true
 43
Author: Mahesh Sapkal, 2014-08-08 11:09:04