1.9.75 • Published 5 years ago

tgt-pkg v1.9.75

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

tgt-pkg

IEG网站质量测试通用模块

安装:

$ npm install --save tgt-pkg

用法:

const tgtest = require('tgt-pkg');

测试

通用测试

mocha test/test.js

可用性测试

mocha test/ux.js

检测:

proCheck方法,检查集成html和请求的json数据流,格式: proCheck.json

tgtest.proCheck(
{
    "config":{
        "isbnAPI":{
            /**
             * ISBN 地址
             * @type    {String}
             */
            "url":"http://x.x.x.x/isbn_api.php?url="
        }
    },
    "custom":{
        /**
         * 检查文件中的文本信息
         * @typedef {object}
         * @property {string} name 检查项的名称
         * @property {string} rule 需要检查的字符,如type为char时支持正则传参,如mode不存在则默认为ig模式匹配
         * @property {string} type 检查的类型  (char 字符,tag 标签/只需填写标签名)
         */
        "file":[
            {"name":"图片","rule":"123.jpg","type":"char"},
            {"name":"图片","rule":"tencent","mode":"g","type":"char"},
            {"name":"div标签","rule":"div","type":"tag"}
        ],
        /**
         * 检查请求中的文本信息
         * @typedef {object}
         * @property {string} name 检查项的名称
         * @property {string} rule 需要检查的字符
         * @property {string} type 检查的类型  (source 请求)
         */
        "request":[
            {"name":"王者统计代码","rule":"somedomain/path/file.ext","type":"source"},
        ]
    },
    /**
     * 需要检查的json数据流
     * @property {object}  //格式https://github.com/allanguys/tgt-pkg/blob/master/assets/proCheck.json
     */
    'json':requestJson
}).then((result)=>{
    console.log(result.checkResult)
})

proCheck方法兼容callback和Promise

- check方法 (tgtest主模块所用检查函数) 检查file文件及请求文件,请求文件格式: check.json

- scoreCheck方法 (评分模块检查函数,参数和回调格式与procheck保持一致)

- monitorCheck方法 (监测模块检查函数,参数和回调格式与procheck保持一致)

tgtest.check({

    "config":{
        /**
         * 通用host
         * @type    {String}
         */
        "host":"x.x.x.x",
        "isbnAPI":{
            /**
             * ISBN 地址
             * @type    {String}
             */
            "url":"http://x.x.x.x/isbn_api.php?url="
        }//host:api host,url:API地址
    },
    /**
     * 用户自定义检查配置
     */
    "custom":{
        /**
         * 检查文件中的文本信息
         * @typedef {object}
         * @property {string} name 检查项的名称
         * @property {string} rule 需要检查的字符,如type为char时支持正则传参,如mode不存在则默认为ig模式匹配
         * @property {string} type 检查的类型  (char 字符,tag 标签/只需填写标签名)
         */
        "file":[
        {"name":"图片","rule":"123.jpg","type":"char"},
        {"name":"div标签","rule":"div","type":"tag"}
        ],
        /**
         * 检查请求中的文本信息
         * @typedef {object}
         * @property {string} name 检查项的名称
         * @property {string} rule 需要检查的字符
         * @property {string} type 检查的类型  (source 请求)
        */
        "request":[
        {"name":"王者统计代码","rule":"ossweb-img.qq.com/images/js/milo/milo-mi1n.js","type":"source"},
        ]
    },
    "file":{
        /**
         * 需要检查的html文件
         * @type    {String}
         */
        "name":filename,
        /**
         * html文件编码格式
         * @type    {String} utf-8/gbk
         */
        "charset":"gbk"
    },
    "request":{
        /**
         * 需要检查的json文件
         * @type    {String}
         */
        "name":filename
    }
},
function(cb){
    //cb.checkResult
})

回调:

//cb.checkResult:
{
    /**
     * 页面是否是标准页面 @type {Boolean}
     */
    pageStandard:"ture",
    /**
     * 页面跳过的检查项:all、title、charset、keywords、description、ping、isbn
     */
    ignore:"none",         
    /**
     * 页面地址
     */
    url:"http://game.qq.com",        
    /**
     * 是否为开发接口拉取的数据   @type {Boolean}
     */
    openapi:"true",
    /**
     * 错误列表
     * @typedef {object}
     * @property {nubmer} error_id 检查项ID
     * @property {string} error_info 出错的具体信息,(为空或者不存在则检查项为正确)
     * @property {string} pass_info 通过的具体信息,可能为空
     * @property {string} name 检查项的具体名称
    */
    list:[
         {
             "error_id": 1002,
             "error_info": "无法检测到页面编码",
             "pass_info": "页面编码正常",
             "name":"编码"
         },         
         {
             "error_id": "custom_file_1",
             "error_info": "个度:122",
             "pass_info": "页面编码正常"
             "name": "div标签"
         }
     ]
}
1.9.75

5 years ago

1.9.74

5 years ago

1.9.73

5 years ago

1.9.72

5 years ago

1.9.71

5 years ago

1.9.7

5 years ago

1.9.5

5 years ago

1.9.4

5 years ago

1.9.3

5 years ago

1.9.2

5 years ago

1.9.1

5 years ago

1.8.9

6 years ago

1.8.8

6 years ago

1.8.7

6 years ago

1.8.6

6 years ago

1.8.5

6 years ago

1.8.4

6 years ago

1.8.3

6 years ago

1.8.2

6 years ago

1.8.1

6 years ago

1.8.0

6 years ago

1.7.9

6 years ago

1.7.8

6 years ago

1.7.7

6 years ago

1.7.6

6 years ago

1.7.5

6 years ago

1.7.4

6 years ago

1.7.3

6 years ago

1.7.2

6 years ago

1.7.0

6 years ago

1.6.9

6 years ago

1.6.8

6 years ago

1.6.7

6 years ago

1.6.6

6 years ago

1.6.5

6 years ago

1.6.4

6 years ago

1.6.2

6 years ago

1.6.1

6 years ago

1.6.0

6 years ago

1.5.6

6 years ago

1.5.5

6 years ago

1.5.4

6 years ago

1.5.3

6 years ago

1.4.3

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.1

6 years ago

1.2.9

6 years ago

1.2.8

6 years ago

1.2.7

6 years ago

1.2.6

6 years ago

1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.9

6 years ago

1.1.8

6 years ago

1.1.7

6 years ago

1.1.6

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago