论坛首页 Web前端技术论坛

使用jslint与qunit保障JS代码质量

浏览 2918 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2013-07-09  
    使用jslint进行语法和风格的检查,可以预防错误。
    vim配置如下:
" jslint
map! lint !D:\jsl-0.3.0\jsl.exe -process %

    打开的JS文本中:lint便可以运行jslint。

    qunit是jquery团队开发的js测试框架,使用很简单。下面是我的项目中用到的一段测试代码:
 <script src="qunit-1.12.0.js"></script>
  <script src="jquery-1.7.2.js"></script>
  <script src="../jquery.column.picker.js"></script>
  <script>
    test( "test basic envirenment", function() {
        ok(typeof jQuery === 'function', "jQuery is a function");
        ok(typeof $("#monthTable").pickout === 'function', "$('#monthTable').pickout is a function");
    });

    test( "test pickout selector function", function() {
        throws( function() {$("#monthTable").pickout()}, /parameter/,  "raised error message contains 'parameter' when parameter is empty");
        ok($.isArray( $("#monthTable").pickout([0, 1, 3]) ), "column index array parameter is ok");
        ok($.isArray( $("#monthTable").pickout("th[name=January],th[name=March]") ), "string selector parameter is ok");
    });

    test( "test pickout show and hide function, compatible to old", function() {
        $("#monthTable").pickout({picked: [0, 1, 2]});
        
        ok($("#monthTable").find("tr th:eq(0)").is(":visible"), "pickout show and hide ok");
    });
  </script>


  
   发表时间:2013-07-10  
试试jasmine, javascript下的BBD库
在给个项目参考:
https://github.com/lvjian700/formdesigner
ruby app -o 0.0.0.0
访问:
http://localhostL4567/index.html
代码在public/rsrc下.
0 请登录后投票
   发表时间:2013-07-11   最后修改:2013-07-11
@witcheryne
jasmine功能很丰富,不错

ps. 你的项目代码有点乱,java,ruby,nodejs什么的
0 请登录后投票
   发表时间:2013-07-11  
lingceng 写道
@witcheryne
jasmine功能很丰富,不错

ps. 你的项目代码有点乱,java,ruby,nodejs什么的

周末整理一下,把readme补全.

生产环境是java
平时开发环境ruby, 主要启个http server用.
node.js 写工具用的,

代码主要在:
rsrc和rspec中。 进入代码index.html, 测试代码test.html



0 请登录后投票
论坛首页 Web前端技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics