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原理
随机推荐
- HDU_1254——推箱子,两次BFS
这题做的一把鼻涕一把泪,果断考虑不周555 Problem Description 推箱子是一个很经典的游戏.今天我们来玩一个简单版本.在一个M*N的房间里有一个箱子和一个搬运工,搬运工的工作就是把箱 ...
- windows shell备忘
1.查找占用80端口的进程idnetstat -aon|findstr "80" 2.查找进程id为"1000"的进程名tasklist|findstr &qu ...
- SKTexture类
继承自 NSObject 符合 NSCodingNSCopyingNSObject(NSObject) 框架 /System/Library/Frameworks/SpriteKit.framewo ...
- Win32 的dll导入
dll 文件可以导入变量,函数,和C++类,但是导入变量会使执行程序与dll紧耦合,而C++类导入则需要两个文件的开发商所用的编译器相兼容,所以做好只导入函数; 创建dll : 头文件:#ifdef ...
- unity3d 版本问题
version: 4.2.1f4 1. 安装以后,不要启动,把exe拷贝覆盖. 2. 断网(重点,不断的话你试试就知道了) 3. 打开unity3d, 点击load License 4. 把ulf导入 ...
- 通过分析 JDK 源代码研究 Hash 存储机制--转载
通过 HashMap.HashSet 的源代码分析其 Hash 存储机制 集合和引用 就像引用类型的数组一样,当我们把 Java 对象放入数组之时,并不是真正的把 Java 对象放入数组中,只是把对象 ...
- 27个Jupyter快捷键、技巧(原英文版)
本文是转发自:https://www.dataquest.io/blog/jupyter-notebook-tips-tricks-shortcuts/ 的一篇文章,先记录在此,等有空时我会翻译成中文 ...
- 全球最流行的66款App的共同规律
根据苹果AppStore.Google Play.App Annie.亚马逊 AppStore及Windows Phone 应用商店历年的公开数据统计,以下66个非游戏类应用正在全球范围内流行,持续时 ...
- Tomcat相关目录及配置文件总结
Tomcat根目录介绍 [bin]目录主要是用来存放tomcat的命令,主要有两大类,一类是以.sh结尾的(linux命令),另一类是以.bat结尾的(windows命令). 很多环境变量的 ...
- Asp.net 回车默认按钮
<head> <script type="text/javascript"> function OnKey() { if (ev ...