业力测试运行没有运行任何测试 [英] karma test runner not running any tests

查看:186
本文介绍了业力测试运行没有运行任何测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是茉莉因缘,随后在线指导,通过使用安装

I'm using karma with jasmine and followed online guide by installing using

npm install --save-dev karma

和其他必需品。

我跑

./node_modules/karma/bin/karma start

karma start karma.conf.js

开辟了显示,业力被连接的外部Chrome浏览器。
我写了一个简单的单元测试一个我的功能似乎在所有测试其没有运行。

which opened up a external chrome browser showing that karma is connected. I wrote a simple unit test for one my functions it seems its not running at tests at all

这是我的人缘配置文件

    // 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
});
 };

我的单元测试

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();

   });

  });

在控制器即时特定功能试图测试

the particular function in the controller im trying to test

(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;
        }
    }
    }]);
   })();

当我运行业力是什么显示在控制台上

what is displayed on the console when i run 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

附加信息:我在轨道上采用了棱角分明-JS红宝石。我知道,有茉莉花的宝石在那里,可以帮助我。但我的老板坚持认为,我们应该尝试使用因缘尽我们的单元测试/ E2E为轨道anuglarjs部分和RSpec。

Additional info: I'm using angular-js with ruby on rails. I'm aware that there is the jasmine gem out there that can help me. But my boss insisted that we should try using karma to do our unit testing/E2E for anuglarjs portion and rspec for rails.

推荐答案

karma.config.js ,设置为 singleRun autoWatch 真正。在您的情况下两者都被设置为false,因此人缘不运行测试。

Under karma.config.js, set either singleRun or autoWatch to true. In your case both of them are set to false, hence karma is not running the tests.

singleRun:如果属实,这抓住了浏览器,运行测试并退出0退出code(如果通过了​​所有测试)或1退出code(如果任何测试失败)。

singleRun: If true, it captures browsers, runs tests and exits with 0 exit code (if all tests passed) or 1 exit code (if any test failed).

singleRun: true

autoWatch:启用或禁用看文件,并执行测试时的这些文件的变化之一。柜面你想看你的文件。

autoWatch: Enable or disable watching files and executing the tests whenever one of these files changes. Incase you want to watch your files.

autoWatch: true

这篇关于业力测试运行没有运行任何测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆