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

待續。。。

 

 

 

 

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM