簡體   English   中英

當*是*測試時,jasmine-node表示“0測試”

[英]jasmine-node says “0 tests” when there *are* tests

我希望這會說“1次測試”,但它會說“0次測試”。 知道為什么嗎? 這是在OS X上。

$ jasmine-node --verbose my.spec.js
undefined

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

$ cat my.spec.js
describe("bar", function() {
  it("works", function() {
    expect("foo").toEqual("foo");
  });
});

$ jasmine-node --version
1.11.0  
$ npm --version
1.3.5  
$ node -v
v0.4.12

即使我嘗試創建語法錯誤,我得到相同的輸出:

$ cat my.spec.js
it(
$ jasmine-node --verbose --captureExceptions my.spec.js
undefined

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

但是,如果我嘗試指定一個不存在的文件,它會抱怨:

$ jasmine-node no.spec.js
File: /tmp/no.spec.js is missing.

我也有這個問題,就是我沒有正確命名文件:

您的規范文件必須命名為spec.jsspec.coffeespec.litcoffee ,它們與正則表達式/spec.(js|coffee|litcoffee)$/i匹配; 否則jasmine-node將找不到它們! 例如,sampleSpecs.js是錯誤的,sampleSpec.js是對的。

資料來源: https//github.com/mhevery/jasmine-node

你應該升級到最新版本的nodejs (目前是0.10.15)

這個問題在filename.In jasmine-node中,文件名應以'spec'* spec.js結尾,例如:helloWorldspec.js或abcspec.js引用文檔:

您的規范文件必須命名為* spec.js,* spec.coffee或* spec.litcoffee,它與正則表達式/spec.(js|coffee|litcoffee)$/i匹配; 否則jasmine-node將找不到它們! 例如,sampleSpecs.js是錯誤的,sampleSpec.js是對的。

在這里閱讀更多。

不要錯過describe

describe("A suite", function() {
  it("contains spec with an expectation", function() {
    expect(true).toBe(true);
  });
});

運行:

c:\Temp>jasmine-node --verbose my.Spec.js

A suite
    contains spec with an expectation

Finished in 0.007 seconds
1 test, 1 assertion, 0 failures, 0 skipped

一切正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM