Javascript jasmine节点测试不是';t运行

Javascript jasmine节点测试不是';t运行,javascript,node.js,jasmine,jasmine-node,Javascript,Node.js,Jasmine,Jasmine Node,我有一个文件word count.js,看起来像这样: function words(statement) { words = {} //some code here that does stuff return words } module.exports = words; 还有一个名为word-count\u test.spec.js的测试套件文件 var words = require('./word-count'

我有一个文件
word count.js
,看起来像这样:

    function words(statement) {
        words = {}
        //some code here that does stuff
        return words
    }

    module.exports = words;
还有一个名为
word-count\u test.spec.js的测试套件文件

var words = require('./word-count');

describe("words()", function() {
  it("counts one word", function() {
    var expectedCounts = { word: 1 };
    expect(words("word")).toEqual(expectedCounts);
  });
  // more tests ... 
});
这两个文件在同一个文件夹中,但当我运行

$ jasmine-node word-count.js


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

为什么测试不起作用

我在错误的文件上运行jasmine节点

我在做什么(不正确):

我应该做什么(正确):


当您运行它时,输出是什么?@jmunsch相同,但发出
未定义的
。问题?您删除的代码中是否存在异步操作?每当我尝试测试我的断言时,我都会添加类似于
expect(1).toBe(2)
的内容,以确保它在担心我的应用程序逻辑之前按预期失败。据我所知,
spec
文件应该放在
spec/
文件夹中。然后运行
jasmine node spec/
应该可以完成这项工作。我想我意识到了问题所在。我不敢相信我忽略了这一点。看看我的答案。
jasmine-node word-count.js
jasmine-node word-count_test.spec.js