Testing framework
both use describe, it functions
Jasmine(Behavior-Driven JavaScript)spyOn(User, "save") jasmine.createSpy()
the Jasmine framework has almost everything built into it including assertions/expectations and test double utilities (which come in the form of spies). However, it does not have a test runner so you will need to use a tool like Karma for that
describe("", function() { var foo; beforEach(function() { foo = 0; }); afterEach(function() { foo = 0; }); xit("", function() { expect(true).toBe(true); }); })
xit, xdescribe(skip test)
其實(shí)Jasmine就是JUnit的JavaScript重寫版
運(yùn)行時(shí)環(huán)境:這里基于chrome瀏覽器,通過(guò)HTML作為JavaScript載體
源文件:用于實(shí)現(xiàn)某種業(yè)務(wù)邏輯的文件,就是.js文件
測(cè)試文件:符合jasmine API的測(cè)試js腳本
輸出結(jié)果: jasmine提供了基于網(wǎng)頁(yè)的輸出結(jié)果
直接open SpecRunner.html,就是跑測(cè)試了
MochaPOS v1 With 3rd Libraries Spec Runner
Mocha includes
test runner
API for setting up your test suite
not include
assertion
test double utilities.
Chai is for assertions when using Mocha.
Sinon is for test doubles in Mocha
Karma just launches an HTTP server, and generates the test runner HTML file.A simple tool that allows you to execute JavaScript code in multiple real browsers.
karma just launches a HTTP server,and generates the test runner HTML file,
karma是一個(gè)基于Node.js的JavaScript測(cè)試執(zhí)行過(guò)程管理工具(Test Runner)。該工具可用于測(cè)試所有主流web瀏覽器,也可集成到CI工具,也可和其他代碼編輯器一起使用,這個(gè)測(cè)試工具的一個(gè)強(qiáng)大特性就是可以監(jiān)控文件的變化,然后自動(dòng)執(zhí)行,通過(guò)console.log顯示測(cè)試結(jié)果。
./node_modules/karma/bin/karma init(用來(lái)生成karma.conf.js配置文件) ./node_modules/karma/bin/karma start karma.conf.js(run test) module.exports = function(config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: "", // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ["jasmine"], // list of files / patterns to load in the browser files: ["*/test/*Spec.js"], // list of files to exclude exclude: ["karma.conf.js"], // preprocess matching files before serving them to the browser // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { }, // test results reporter to use // possible values: "dots", "progress" // available reporters: https://npmjs.org/browse/keyword/karma-reporter reporters: ["progress"], // web server port port: 9876, // enable / disable colors in the output (reporters and logs) colors: true, // level of logging // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG logLevel: config.LOG_INFO, // enable / disable watching file and executing tests whenever any file changes autoWatch: true, // start these browsers // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher browsers: ["Chrome"], // Continuous Integration mode // if true, Karma captures browsers, runs the tests and exits singleRun: false, // Concurrency level // how many browser should be started simultaneous concurrency: Infinity }) }Enzyme
JavaScript Testing utilities for React
Jest它提供了一種“零配置”的開發(fā)體驗(yàn),并具備諸多開箱即用的功能,比如 mock 和代碼覆蓋率。你不僅可以將此測(cè)試框架應(yīng)用于 React.js 應(yīng)用程序,也可以應(yīng)用于其他 JavaScript 框架。
npm i jest-cli -g jest src/helpers/__test__/a.jsTesting Assertions
Chai/Expect/Should
UI testselenium
webdriverio
webdrivercss
https://www.codementor.io/jav...
http://stateofjs.com/2016/tes...
文章版權(quán)歸作者所有,未經(jīng)允許請(qǐng)勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。
轉(zhuǎn)載請(qǐng)注明本文地址:http://www.ezyhdfw.cn/yun/90121.html
摘要:下面會(huì)講解如何使用以及,來(lái)為我們的代碼編寫測(cè)試。我們不妨先選擇前者綜上所述,我們要使用組合來(lái)為我們的代碼寫測(cè)試。他們分別會(huì)在每個(gè)測(cè)試的之前和之后執(zhí)行一次。副本最后還有一個(gè)問(wèn)題是如何結(jié)合來(lái)為我們的代碼編寫測(cè)試。 下面會(huì)講解如何使用 karama, jasmine 以及 webpack,來(lái)為我們的 ES6 代碼編寫測(cè)試。(最后我寫了一個(gè)可用的例子,請(qǐng)查看 ES2015-Starter-Ki...
摘要:核心功能就是啟動(dòng)一個(gè)服務(wù)并監(jiān)聽(tīng)項(xiàng)目文件改變,文件改變后再刷新服務(wù)器。 Karma 簡(jiǎn)介 Karma是Testacular的新名字,在2012年google開源了Testacular,2013年Testacular改名為Karma。Karma是一個(gè)讓人感到非常神秘的名字,表示佛教中的緣分,因果報(bào)應(yīng),比Cassandra這種名字更讓人猜不透! Karma是一個(gè)基于Node.js的JavaS...
摘要: Awesome JavaScript A collection of awesome browser-side JavaScript libraries, resources and shiny things. Awesome JavaScript Package Managers Loaders Testing Frameworks QA Tools MVC Framew...
摘要:方法的參數(shù)是一個(gè)函數(shù),所有數(shù)組成員依次執(zhí)行該函數(shù),返回結(jié)果為的成員組成一個(gè)新數(shù)組返回自己寫的代碼扶額 https://stackoverflow.com/que... The difference is in the return values. .map() returns a new Array of objects created by taking some action on...
摘要:使用可以快速生成一個(gè)項(xiàng)目,其中包含了和以及覆蓋率統(tǒng)計(jì)的配置參考一個(gè)創(chuàng)建測(cè)試腳本的快速方法其他參考資料前端自動(dòng)化測(cè)試概覽測(cè)試之使用對(duì)項(xiàng)目進(jìn)行單元測(cè)試 showImg(https://segmentfault.com/img/bVbjfXr?w=600&h=317); 前言 測(cè)試可以提供快速反饋,根據(jù)測(cè)試用例覆蓋代碼,從而提升代碼開發(fā)效率和質(zhì)量。根據(jù)投入產(chǎn)出價(jià)值,通常迭代較快的業(yè)務(wù)邏輯不做...
閱讀 2204·2023-04-25 22:42
閱讀 2329·2021-09-22 15:16
閱讀 3559·2021-08-30 09:44
閱讀 560·2019-08-29 16:44
閱讀 3387·2019-08-29 16:20
閱讀 2604·2019-08-29 16:12
閱讀 3466·2019-08-29 16:07
閱讀 741·2019-08-29 15:08