UI tests using Karma for long browsers

Source: Internet
Author: User
Tags autowatch

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.