1. The entire project file is divided into three folders: build, spec, src, package.json, Gruntfile.js
2. Since the source file is packaged with Grunt, the output of the compiled source file is knockoutjs.js, according to the README.md file. Install
3. The source code has test files under the spec folder. You can run tests using PhantomJS, PhantomJS (it fully supports the web without browser support, its fast, natively supports various web standards: DOM manipulation, CSS selectors, JSON, Canvas, and SVG. PhantomJS can be used for page automation , network monitoring , web page screenshots , and no-interface testing , etc. ). You can download it before installation
You can also open the spec/runner.html file directly in the browser to view the test case without phantomjs. The test case is used
4. The main function content of the runner.html file under the spec
1 <script type="text/javascript"> 2 (function() { 3 var jasmineEnv = jasmine.getEnv(); 4 jasmineEnv.updateInterval = 500; 5 6 var htmlReporter = new jasmine.HtmlReporter(); 7 jasmineEnv.addReporter(htmlReporter); 8 jasmineEnv.specFilter = htmlReporter.specFilter; 9 10 var testlingParam = /[?&]testling=true/.test(location.href); 11 if (testlingParam) 12 jasmineEnv.addReporter(new jasmine.TapReporter()); // For Testling CI 13 jasmineEnv.execute(); 14 })(); 15 </script>
通常这是固定的写法。会把测试用例的结果输出在页面中。
5.熟悉Jasmine
1.页面需要引用jasmine 这几个文件
2.Jssmine 的测试用例编写
一个文件一个describe,几个测试用例就几个it
6.根据源码提供的测试用例熟悉knockoutjs 的API。