AngularJs开发环境搭建

1. 安装Sublime Text3

常用插件安装:AngularJs, Autoprefixer, BracketHighlighter,ConvertToUTF8,CSScomb,DocBlockr,Emmet,Git,GitGutter,Jquery,JsFormat,SideBarEnhancements,SublimeCodeIntel,SublimeLinter(jshint,csslint),Tag,Terminal,TrailingSpaces

其中SublimeLinter需要用到NodeJs,并安装jshint和csslint, npm install -g jshint

2. 安装Bower依赖

安装好Bower后,通过bower install 安装angularjs  bootstrap

3. 搭建单元测试环境

karma 单元测试容器

karma-jasmine 编写单元测试

karma-coverage 代码覆盖率

karma-firefox-launcher 

初始化配置文件 karma init

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.

> yes

注:需不需要引入requirejs

引入requirejs的原因:加载相互依赖的js文件

Do you want to capture a browser 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.

> 

注:karma启动时加载的目标文件和测试文件

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

注:karma要不要动态监听目标文件和测试用例变化

Config file generated at "D:\workspace\javascript\karma\karma.conf.js".

这个指令跑完后你就会发现目录底下多了个配置文件karma.conf.js,test-main.js

karma.conf.js:  karma配置文件

test-main.js:    requireJS配置文件

 运行测试用例  karma start

4. 搭建集成测试环境

 Protractor

待续。。。

 

 

 

 

 

 

 

 

 

 

posted @ 2016-09-02 13:26  wpblog  阅读(1786)  评论(0编辑  收藏  举报