collaboration between Karma and Angular is like peanut butter and jelly.
You only need to define the configuration file in Karma to start it, and then it will automatically execute the test case in the expected test environment. You can create a test environment in the configuration file. Angular-seed is a fast implementation solution that I strongly recommend. In my recent project, Karma is configured as follows:
?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
returned to the object.2 Jasmine2.1 IntroductionJasmine is a behavior-driven JavaScript testing framework that does not depend on any other JavaScript framework. It has a clean and clear syntax, so you can write the test code very simply. For JavaScript-based development, it is a good test framework choice.2.2 Use steps to explore(1) Download Jasmine: https://github.com/pivotal/jasmine/releasesIntroduction
It can be used for entertainment projects to get together idioms and determine whether the received value is an idiom. None? Php *** Jasmine robot Website: www.itpk.cn * Jasmine robot online experience: www. itpk. cnexperience. php * header (Content-type: textplain; charsetutf-8 );
It can be used for entertainment projects to get together idioms and determine whether the received value is an idiom. None? Ph
Http://developer.51cto.com/art/201506/479127.htm using grunt to build an automated web front-end development environment-complete tutorial (just introduced JS, CSS compression and file change monitoring)http://blog.csdn.net/puncha/article/details/18384289Http://karma-runner.github.io/0.13/intro/installation.htmlHttp://karma-runner.github.io/0.13/config/configuration-file.htmlHttp://blog.fens.me/nodejs-karma-jasmine/Karma and
for optimization. How can this problem be solved? You only need to add msgStore as the dependency of the application module. Although this is not perfect, it is enough in most cases.
// app.js'use strict';export default require('angular').module('lazyApp', [require('angular-ui-router'),require('oclazyload'),// msgStore as global dependencyrequire('commons/msg-store').name,require('./pages/home/home.routing').name,require('./pages/messages/messages.routing').name,]);
Unit Test skills
Changing
the coverage information is sent back to the server to generate the test report.
Then execute the unit test, and the statistical information will be mounted to the global variable.thisBelow. For the browser environment,thisYeswindowFor the nodejs environmentthisYesglobal.3. generate a report)
This step generates reports in specific formats, such as html, lcov, cobertura, and teamcity, based on the coverage information in the global scalar.Example
//source codefunction abs(num){ if(abs > 0)
companies do not engage in the separation of the front and back, the increase of complexity! Unit TestAfter the front-end separation, it means that more business logic will be incorporated into the front-end program, corresponding to the need for front-end engineers to complete the corresponding business logic unit testing to ensure that the front-end quality will not gradually fall.
JavaScript-based unit testing proved to be an efficient test method in which 71% of organizations perfo
tests in angularjs to encourage developers to write more about them.When writing tests, ANGULARJS developers tend to use the syntax in the Jasmine behavior-driven Development (BBD) framework. Although ANGULARJS does not force you to use Jasmine, all of the tests we have in the tutorial are written using Jasmine. You can get the information on Jasmine's official
in the page.5. Familiar with Jasmine1. The page needs to reference jasmine these files script type="text/javascript" src="Lib/jasmine-1.2.0/jasmine.js ">/script> script type="text/javascript" src="lib/jasmine-1.2.0/ Jasmine-html.js ">/script> -- script type="text/javascript" src="Lib/jasmine.exte
get a deeper understanding of the scope of ANGULARJS, see the ANGULARJS scope documentation.
Test
The "Angularjs Way" makes development-time code testing very simple. Let's take a look at this new unit test added for the controller:
Test/unit/controllersspec.js:
Describe (' phonecat controllers ', function () {
describe (' Phonelistctrl ', function () {
It (' should create ') Phones "model with 3 phones", function () {
var scope = {},
Ctrl = new Phonelistctrl (scope);
Next Monday, prepare to go to the company's JavaScript TDD training camp. Previously just scattered use of JavaScript, level equivalent to small white, clumsy birds have, in advance to the environment tinker.Steps:1.nodejs InstallationDownload the pkg package to http://www.nodejs.org/. And then all the way next. Get installation path prompt after installationNode is installed at/usr/local/bin/nodeNPM is installed at/usr/local/bin/npmMake sure That/usr/local/bin are in your $PATH.This nodejs the
at the initial stage of development, it's often difficult to get back to work.
Luckily, we now have a great test architecture that is very useful and powerful, just like the other languages you already use. The two main frameworks are Jasmine and Mocha.
In the past I have used two, and finally chose the latter, Mocha. Its main advantage is that when you have to work with asynchronous coding, it is the most commonly used method in the development of
PHANTOMJS is a WebKit-based server-side JavaScript API that is published based on the BSD open source protocol. PHANTOMJS supports the web without browser support, and natively supports a variety of web standards such as DOM processing, JavaScript, CSS selectors, JSON, canvas, and Scalable Vector graphics svg. Phantomjs is mainly through JavaScript and Coffeescript control the WebKit CSS selector, Scalable Vector graphics SVG and HTTP network and other modules. Phantomjs mainly supports Windows,
Testing
Unit testing is a good thing. PHP has PHPUnit and Javascript Has Jasmine. The quality of software must be guaranteed by these test points. When developing PHP, I must write one where I can use unit tests. The advantage of writing a unit test in PHP is to determine whether the function is correct in advance and verify the unknown. A large number of unit tests can ensure the software quality, so that the tester is convenient. I also write unit
index.html, you can manually fill the above two entries into the index.html, but yeoman will automatically fill you in. Use CTRL + C to stop the current command line, then restart the server, then run Grunt serve. You'll see that the script section is filled with jquery-ui/ui/jquery-ui.js and angular-ui-sortable/sortable.js.At the same timeScripts/app.jsIn the file, addui.sortableCode, such as:Finally, we should edit main.html, plus the corresponding code, the entire TODO List section code is a
Use node + grunt + bower + Karma + Jasmine to build a front-end development environment. (For example, Windows environment)
tools for installing development kits : Node (development and test kit, such as installing Grunt,bower,karma,karma-jasmine)
build tool: Grunt (Merge, code check, compression, etc., and can be inserted into other tasks)
js Library Dependency managemen
Connection between left and right of mysql and internal connection of cainiao1. create a table: boy and insert several lines of data. Java code: create table boy (Name varchar (10 ),Flower varchar (10)); Java code insert into boyValues("Lin shuhao", "Rose "),("Liu Xiang", "Peach Blossom "),("Jay Chou", "Jasmine "),("Sharp brother", "Lotus "),("Andy Lau", "dog tail flower ");2. create a table: girl and insert several rows of data. Java code: create tab
Svg.For web testing, interface, network capture, page Automation access, etc. can be said to be handy. Baidu has done a lot of practice on this platform.
Functional Testing
Casperjs
http://casperjs.readthedocs.io/en/latest/http://casperjs.org/
Casperjs is a PHANTOMJS package that provides a more user-friendly API and enhanced testing support.
Functional Testing
Slimerjs
Http://www.slimerjs.org/index.html
Slimerjs is similar to Phantomjs,
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.