小编Ray*_*rea的帖子

按文件夹分组伊斯坦布尔代码覆盖率报告

我正在使用istanbul和nyc命令为NodeJs运行代码覆盖率报告.

我正在使用mocha进行单元测试

我按照预期得到了每个文件的报告,但我希望看到的是一个包含单个目录摘要的报告.让我更详细地解释一下,我正在阅读我想要看到的内容

我的所有源文件都在一个文件夹中,我想查看该文件夹的摘要,而不是该文件夹中每个文件的完整列表

这是我的文件夹结构的样子

// This is the folder where all the sources are at 
src
    // This is the folder where coverage is output
    coverage
        NodeJs
            index.html
    file1.js
    file2.js
    file3.js
    // This is the folder where all tests are at
    tests
        test_file1.js
        test_file2.js
        test_file3.js
Run Code Online (Sandbox Code Playgroud)

我的.babelrc文件看起来像这样

{
    "presets": ["es2015", "stage-2"],
    "plugins": [
        [
            "istanbul",
            {"exclude": ["**/tests/*.js"]}
        ]
    ]
}
Run Code Online (Sandbox Code Playgroud)

我正在使用以下命令来运行我的测试覆盖率

node ./node_modules/.bin/nyc --reporter=html \
    --report-dir=./src/coverage/NodeJs \
    ./node_modules/mocha/bin/_mocha \
    --require babel-core/register \
    --ui bdd src/tests/test*.js
Run Code Online (Sandbox Code Playgroud)

我的所有测试运行正常,它们通过,报告src/coverage/NodeJs/index.html按预期输出到文件.在浏览器中,该报告看起来像这样: …

javascript node.js istanbul nyc

9
推荐指数
1
解决办法
892
查看次数

jQuery UI Position设置"right"和"bottom"而不是"left"和"top"

好的,这是我的问题.使用jQuery UI位置.可以将元素相对于屏幕上的另一元素定位.它在要定位的元素上设置左侧和顶部css属性,将其定位在屏幕上.

我想要做的不是设置左侧和顶部,而是想要设置右侧和底部,以便如果定位元素增大或缩小,它将以正确的方向增长/缩小.

让我详细介绍一下.好吧,我想要的是如果一个元素位于它的右边,那么我想设置rightcss属性而不是left如果一个元素位于它的底部,那么我想设置bottom而不是top.我可以使用usingjQuery UI Position 的属性来做到这一点,但我遇到了碰撞检测的问题.如果碰撞检测设置为flip和元素被翻转,我要进行检测,并找出我是否需要进行设置right,而不是leftbottom代替top.查看下面的代码,以更好地了解我正在尝试做什么.

$('#somediv').position({
    my: 'right bottom',
    at: 'right top',
    of: $('#someotherdiv'),
    offset: '0 5',
    collision: 'flip flip',
    using: function(pos) {

      // Figure out the right and bottom css properties 
      var right = $(window).width() - pos.left - $(this).outerWidth(true);
      var bottom = $(window).height() - pos.top - $(this).outerHeight(true);

      // Position the element so that right and bottom are …
Run Code Online (Sandbox Code Playgroud)

javascript jquery jquery-ui

8
推荐指数
1
解决办法
8558
查看次数

标签 统计

javascript ×2

istanbul ×1

jquery ×1

jquery-ui ×1

node.js ×1

nyc ×1