【问题标题】:Why jasmine-node doesn't find my spec files?为什么 jasmine-node 找不到我的规范文件?
【发布时间】:2012-02-22 03:37:53
【问题描述】:

我已经使用 npm 安装了 jasmine-node。我的项目目录结构如下:

|-lib\
   |-taxCalc.js
|-spec\
   |-taxCalc.spec.coffee
   |-taxCalc.spec.js
|-src\
   |-taxCalc.coffee

当我使用以下命令(对于 CoffeeScript)从根文件夹运行 jasmine-node 时:

jasmine-node --coffee --verbose spec

Finished in 0.015 seconds
0 tests, 0 assertions, 0 failures

如果我运行 JavaScript 版本也是一样。

如果我明确指出规范文件测试运行良好:

jasmine-node --coffee --verbose spec/taxCalc.spec.coffee

Tax calculation
  calculates tax

Finished in 0.009 seconds
1 test, 1 assertion, 0 failures

文档说文件名应该以“spec.js”或“spec.coffee”结尾,所以一切看起来都很好。

附:我在 Windows 7 上运行。

【问题讨论】:

  • 我唯一知道的是windows需要node.js中的路径以不同方式处理。例; “C:/bla”需要是“C:\/bla”。可能是 jasmine 的开发者没有在 windows 上测试..
  • 感谢您的想法 - 如果找到 Windows 特定路径,我将尝试测试 jasmine-node 中使用的 RegEx。
  • 我在 Windows 中有一个与您的结构相似的项目,但我没有遇到您的问题。如果您更明确地说规范是一个目录,这会有所不同吗:jasmine-node --coffee --verbose .\spec\
  • 不,更明确的版本没有帮助。我测试了 jasmine-node 中使用的 RegEx,它很好。
  • 老兄,抛弃茉莉花。我曾经使用 Jasmine,直到 Mocha 出现。

标签: javascript node.js coffeescript jasmine


【解决方案1】:

Jasmine-node 已在上周更新为使用 walkdir 而不是 findit,现在它可以在 Windows 中运行。重新运行npm install jasmine-node 进行更新。

【讨论】:

    【解决方案2】:

    偶然发现了同样的问题,并且太晚了阅读 MarisKs 链接:/ - 但得出了与问题中描述的相同的结论: 至少在 Windows 7 上,file.stat.ino 总是返回 0,所以 findit/index.js 中的函数 createInodeChecker() 总是返回 true 并且文件将被跳过。

    最简单的即时修复:将 createInodeChecker 编辑为

    function createInodeChecker() {
        var inodes = {};
        return function inodeSeen(inode) {
            if (inode == 0) {
                return false;
            }
    
            if (inodes[inode]) {
                return true;
            } else {
                inodes[inode] = true;
                return false;
            }
        }
    }
    

    不好,但你可以使用它。

    【讨论】:

    猜你喜欢
    • 2014-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多