avalon1.6 developed almost, this time using advanced development concepts for development, such as modular, unit testing what ...
UI testing is an important link before using Ali's Totoro, but opening the browser is inconvenient. So from Webdrieverio, Nightwatch, always find karma!
Karma's official website is particularly rotten, I've been doing it for a long time to run.
The NPM modules used are:
Karmakarma-mochakarma-mocha-reporterkarma-firefox-launcherkarma-chrome-launcherkarma-opera-launcherkarma-safari-launcher
Add Karma.config.js under your project
Module.exports = function (config) {config.set ({basepath: ", Frameworks: [' Mocha '], files: [ {pattern: ' node_modules/chai/chai.js ', include:true}, ' Karma/index.js '], exclude: [], Reporters: [' Mocha '], Mochareporter: {output: ' Autowatch ', colors: {s Uccess: ' Green ', info: ' Bggreen ', Warning: ' Cyan ', error: ' Bgred ' }}, port:9876, Colors:true, Loglevel:config. Log_info,//autowatch for True,karma will automatically execute the test case autowatch:true,//http://www.cnblogs.com/netsos/p/4371075.html Brow Sers: [' Opera ', ' Chrome ', ' Firefox ', ' Safari '], Singlerun:false, plugins: [' Karma-mocha ', ' Karma-mocha-reporter ', ' karma-firefox-launcher ', ' karma-chrome-launcher ', ' Karma-ope Ra-launcher ', ' Karma-safari-launcher '})}
Then we build a directory called Karma in this project, built Index.js
/** * Created with IntelliJ idea. * User:shenyanchao * DATE:3/5/13 * time:5:51 PM * To change this template use File | Settings | File Templates. */var assert = Chai.assert;var should = Chai.should ();d escribe (' Array ', function () {before (function () {CONSOLE.L OG (' This called-before all '); }); Beforeeach (function () {Console.log (' invoke before each method '); }); Aftereach (function () {Console.log (' invoke after each method '); }); After (function () {Console.log (' the ' This called-all '); }); Describe (' #indexOf () ', function () {It (' should return-1 when the value was not present ', function () {cons Ole.log (' Invoke one assert '); Assert.equal ( -1, [1,2,3].indexof (5)); Assert.equal ( -1, [1,2,3].indexof (0)); }); }); Describe (' #indexOf () ', function () {It (' should return-1 when the value was not present ', function () {cons Ole.log (' Invoke second should '); [1,2,3].indExof (5). Should.equal (-1); [1,2,3].indexof (0). Should.equal (-1); }); });})
Then execute the Karma Start command to see the effect.
You can't read it.
UI tests using Karma for long browsers