Knockoutjs Read source

Source: Internet
Author: User

1. The entire project file is divided into build,spec,src three folders, package.json,gruntfile.js

2. Because the source file is packaged in grunt, the source file to be compiled is output as knockoutjs.js, according to the readme.md file. Installation

npm install-g grunt-cliNPM InstallGruntThe resulting file is saved in thebuild/output/Folder.

3. The source code with the test file, is under the Spec folder. You can use PHANTOMJS to run tests, PHANTOMJS (which fully supports the web without the need for browser support, its fast, native support for various web standards: DOM processing, CSS selectors, JSON, Canvas, and SVG.PhantomjsCan be used for page automation, network monitoring , Web screenshot , and no interface test ). You can download it first before installing

http://phantomjs.org/download.html

You can also use PHANTOMJS. Open the spec/runner.html file directly in the browser to view the test cases. Test cases are used

Jasmine to write a test case

Main function contents of the runner.html file under 4.spec

1<script type="Text/javascript">2 (function () {3             varJasmineenv =jasmine.getenv ();4Jasmineenv.updateinterval = -;5 6             varHtmlreporter =NewJasmine. Htmlreporter ();7 Jasmineenv.addreporter (htmlreporter);8Jasmineenv.specfilter =Htmlreporter.specfilter;9 Ten             varTestlingparam =/[?&]testling=true/. Test (LOCATION.HREF); One             if(Testlingparam) AJasmineenv.addreporter (NewJasmine. Tapreporter ());//For testling CI - Jasmineenv.execute (); -           })(); the</script>

Usually this is a fixed notation. The result of the test case is output in the page.

5. Familiar with Jasmine

1. 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>      <!--our Jasmine extensions -- <script type="text/javascript" src="Lib/jasmine.extensions.js" C11>></script>

Test case Writing for 2.Jssmine

A file a describe, several test cases on several it

  

describe(' A Suit ', function() {   Beforeeach(function () {//code executed each time it executes});Aftereach(function () {//Execute code after it is finished});it (' A test ', function () {expect (").toequal (");//Ecpect Assertion});});

6. Familiarize yourself with the Knockoutjs API based on the test cases provided by the source code.

Knockoutjs Read source

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.