Install and use Karma
1:安装karma
y@y:~$ npm install --global karma
2:安装karma插件
y@y:~$ npm install --global karma-jasmine karma-chrome-launcher
运行Karma:
y@y:~$ .npm-packages/lib/node_modules/karma/bin/karma start
INFO [karma]: Karma v0.12.32 server started at http://localhost:9876/
3:安装karma,命令行插件
y@y:~$ npm install -g karma-cli
测试:
y@y:~$ karma --version
Karma version: 0.12.
y@y:~$ karma start
INFO [karma]: Karma v0.12.32 server started at http://localhost:9876/
4:配置Karma
y@y:angular-test$ karma init my-karma.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 any browsers automatically ?
Press tab to list possible options. Enter empty string to move to the next question.
> Chrome
> 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
WARN [init]: There is no file matching this pattern. > test/*Spec.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 "/home/y/my_note/nodejs/angular-test/my-karma.conf.js". y@y:angular-test$ ll
总用量
drwxrwxr-x y y 5月 : ./
drwxrwxr-x y y 5月 : ../
drwxrwxr-x y y 5月 : app/
drwxrwxr-x y y 5月 : bower_components/
drwxrwxr-x y y 5月 : .idea/
-rw-rw-r-- y y 5月 : my-karma.conf.js
drwxrwxr-x y y 5月 : test/
y@y:angular-test$
5:修改项目下面的my-karma.conf.jsp配置文件,将需要的js文件引入:
// list of files / patterns to load in the browser
files: [
'bower_components/angular/angular.min.js',
'bower_components/angular-mocks/angular-mocks.js',
'app/js/*.js',
'test/*Spec.js'
],
6:进行运行测试:
@y:angular-test$ karma start my-karma.conf.js
INFO [karma]: Karma v0.12.32 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 39.0. (Linux)]: Connected on socket cz6gdNTkD5A0FyfLAAAA with id
Chrome 39.0. (Linux): Executed of SUCCESS (0.021 secs / 0.016 secs)
Install and use Karma的更多相关文章
- AngularJS中使用Karma单元测试初体验
■ 搭建karma测试环境 → 创建app和test文件夹→npm install karma --save-dev→npm install karma-jasmine --save-dev→npm ...
- Karma和Jasmine自动化单元测试
从零开始nodejs系列文章,将介绍如何利Javascript做为服务端脚本,通过Nodejs框架web开发.Nodejs框架是基于V8的引擎,是目前速度最快的Javascript引擎.chrome浏 ...
- karma+seajs
下面的介绍以karma能正常运行为前提,看karma系列文章:http://www.cnblogs.com/laixiangran/tag/Karma/ 目录结构 步骤 安装 npm install ...
- karma+requirejs
下面的介绍以karma能正常运行为前提,看karma系列文章:http://www.cnblogs.com/laixiangran/tag/Karma/ 目录结构 步骤 安装 npm install ...
- jasmine+karma 自动化单元测试
测试的必须性 相信大家都知道测试的必要性,测试先行的概念.不过,写了这么多年的代码,除了之前用java的时候写过一些测试用例,还真的很少写过前端的测试用例,或者做一些自动化测试.感觉做单元测试还是很有 ...
- Karma和Jasmine自动化单元测试——本质上还是在要开一个浏览器来做测试
1. Karma的介绍 Karma是Testacular的新名字,在2012年google开源了Testacular,2013年Testacular改名为Karma.Karma是一个让人感到非常神秘的 ...
- 在本地创建angular-ui/bootstrap项目
在本地创建完整的angular-ui/Bootstrap项目 git clone the repo, then switch to the tag you want,then use grunt bu ...
- angularjs自动化测试系列之karma
angularjs自动化测试系列之karma karma test with jasmine 更好的利用工具是为了让生活更美好. 需要安装的东西: npm install karma -g mkdir ...
- karma单元测试入门
学习angularjs,都会遇到karma单元测试,可是初学者面对复杂的测试配置往往不知从何入手,下面我们将抛开angularjs,单独使用两个js文件,完成一次测试入门. 0,karma原理
随机推荐
- unittest笔记
学习资料: 官网: https://docs.python.org/2.7/library/unittest.html IBM Python自动单元测试框架: http://www.ibm.com/d ...
- Selenium webdriver 开始
最早接触的selenium是 selenium IDE,当时是为了准备论文.为了用IDE还下载了Firefox浏览器.后来接触过两个项目都需要selenium,一个采用selenium webdirv ...
- N - Marriage Match II - HDU 3081(最大流)
题目大意:有一些男孩和女孩玩一个游戏,每个女孩都可以挑一个男孩来进行这个游戏(所有人都要参加),女孩只会挑选她喜欢的男孩,并且她们认为她们朋友喜欢的男孩她们也是喜欢的(朋友的男朋友也是我的男朋友??? ...
- 一种用单片机AD采样方式来检测交流市电电压的方法
下面介绍一种用单片机AD采样的方式检测市电电压的方法 要检测交流市电的电压,通常有两种方法 一.通过频繁的采样后再求平均值来获得实际电压值 二.通过采样交流市电的峰值,再通过算法得出实际电压值 这里 ...
- requirejs2读书笔记
If you want to do require() calls in the HTML page, then it is best to not use data-main. data-main ...
- WebView redirect https to http
最新项目大改版,刚好对相关sdk版本做了下升级,target也从19升级到21. 意外发现原先在WebView中加载的网页中的图片全都变得一片白,连默认图片都不给显示. 经过一番测试才发现是由于tar ...
- OpenStack Summit Paris 会议纪要 - 11-04-2014
前言: 来源:https://wiki.openstack.org/wiki/Summit/Kilo/Etherpads#Ops 不一定翻译准.由于是在summit上随手写的. 重点关注Ops Sum ...
- asp.net总结(一)
前言 asp.net的视频不是很多,但是中间由于毕业论文等一些事情.花的时间比较长,知识所以整体上学习的也不是很连贯 打算在总结的时候来复习一下这些知识.只能是大概的来了解asp.net到底有哪些东西 ...
- hdu 2104
#include <iostream> using namespace std; int gcd(int a,int b) { return (b?gcd(b,a%b):a); } int ...
- javascript获取CSS3浏览器前缀
var prefix = (function () { var styles = window.getComputedStyle(document.documentElement, ''), pre ...