Karma是由Google團隊設計的一款前端測試運行框架,主要用于Java性能測試,進行浏覽器測試代碼、自動生成覆蓋率報告、持續集成服務器上執行測試等,只需編寫代碼並從測試中立即獲得結果,提高設計效率,需要的朋友可以來本站下載!

軟件特色
1、在真正的設備測試
测试你的真正的浏览器和真实设备如手机的代码,或者在一个无头phantomjs 片。
2、遙控
控制从命令行或IDE -整个工作流 只保存一个文件和业力将运行所有的测试。
3、測試框架無關
描述你的測試量子系統,或寫任何你喜歡的一個簡單的適配器框架。
4、開放源代碼
開發和維護的開源社區GitHub。
5、調試方便
調試容易直接從你的IDE通過webstorm或谷歌浏覽器。
karma支持三個命令
start[<configFile>] [<options>] 启动 Karma 持续执行,也可以执行单次的测试,然后直接收集测试结果.
init[<configFile>]初始化配置文件.
run [<options>] [ -- <clientArgs>] Trigger a test run.
Karma配置測試教程
karma配置
初始化测试 $ karma init (按照提示下一步下一步结束后会生产配置文件:karma.conf.js)
1. Which testing framework do you want to use ? (mocha)
2. Do you want to use Require.js ? (no)
3. Do you want to capture any browsers automatically ? (Chrome)
4. What is the location of your source and test files ? (test/**.js)
5. Should any of the files included by the previous patterns be excluded ? ()
6. Do you want Karma to watch all the files and run the tests on change ? (yes)
karma自動化測試
編寫符合語法的測試js腳本
test.js :
describe('jQuery', function () {
it('should have jQuery', function () {
if (!window.jQuery) {
throw new Error('查看下 karma.conf.js 配置项 files 是否正确')
}
});
});
启动测试 $ karma start
查看浏覽器控制台輸出信息