RequireJS + AngularJS Seed 11 _Karma

看起来 Karma 的配置不是很多,可以把Karma官网的介绍简单学习一下。

安装,一如既往的 npm,又要去网吧了:

<!-- lang: js -->
// 安装Karma
npm install karma -g 

// 按需安装插件(框架/浏览器支持)
npm install karma-jasmine karma-chrome-launcher --save-dev 

// 按需安装,每次都打 ./node_modules/karma/bin/karma start 太傻逼
// 装个 cli 就好了。
npm install -g karma-cli 

配置,看到这个多少明白了一点其中道理:

<!-- lang: js -->
$ karma init my.conf.js

Which testing framework do you want to use ?
Press tab to list possible options. Enter to move to the next question.
> jasmine

Do you want to use Require.js ?
This will add Require.js plugin.
Press tab to list possible options. Enter to move to the next question.
> no

Do you want to capture a browser automatically ?
Press tab to list possible options. Enter empty string to move to the next question.
> Chrome
> Firefox
>

What is the location of your source and test files ?
You can use glob patterns, eg. "js/*.js" or "test/**/*Spec.js".
Enter empty string to move to the next question.
> *.js
> test/**/*.js
>

Should any of the files included by the previous patterns be excluded ?
You can use glob patterns, eg. "**/*.swp".
Enter empty string to move to the next question.
>

Do you want Karma to watch all the files and run the tests on change ?
Press tab to list possible options.
> yes

Config file generated at "/Users/vojta/Code/karma/my.conf.js".

简单看一下配置选项的意义:(简单吗?不简单吗?)

 - autoWatch:"true"                  // 监控文件变化立刻进行测试。貌似grunt有自己的理解
 - autoWatchBatchDelay:"250"        // 重启测试的间隔,有利于批处理
 - basePath:""                      // 根目录,相对路径。files 和 exclude 用的
 - browserDisconnectTimeout:"2000"  // (ms)玩失踪多久判定死亡
 - browserDisconnectTolerance:"0"   // (ms)玩失踪多少次判定死亡
 - browserNoActivityTimeout:"10000" // (ms)装死多久算死亡
 - browsers:[]                      // 测试的目标浏览器,PhantomJS是随Karma一起装好的
 - captureTimeout:60000             // 启动时,浏览器启动容忍时间,Karma会给三次机会
 - client.args:undefined            // karma run --xxx 启动参数
 - colors:true                      // log和报告输出的时候是否有颜色……好功能
 - exclude:[]                       // 不需要加载的文件
 - files:[]                         // 需要加载的文件
 - frameworks:[]                    // 测试框架 ['jasmine'], ['mocha'] or ['qunit']……
 - hostname:"locaohost"             // 测试用的host
 - logLevel:config.LOG_INFO         // log输出等级
 - loggers:[{type: 'console'}]      // log输出方式
 - plugins:['karma-*']              // Karma用到的插件
 - port:9876                        // 测试用端口
 - preprocessors:{'**/*.coffee': 'coffee'}  // 预处理映射(不懂啊)
 - proxies:{}                       // 路由映射 proxies: { '/static': 'http://gstatic.com',}
 - proxyValidateSSL:true            // 发现SSL证书异常是否报错
 - reportSlowerThan:0               // 显示太慢的测试,默认是全部,因为0(ms)
 - reporters:['progress']           // 报告方式,比如 growl, junit, teamcity or coverage
 - singleRun:false                  // 独立模式,true 的话会对所有配置过的浏览器都进行测试
 - transports:['websocket', 'flashsocket', 'xhr-polling', 'jsonp-polling'] // 通信模式
 - client.useIframe:true            // 以 iframe 运行或者启动新窗口
 - client.captureConsole:true       // 获取所有控制台输出并把它们的输出显示到终端
 - urlRoot:'/'                      // Karma 运行的 base url

转载于:https://my.oschina.net/ilivebox/blog/265558

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值