2013-03-18 67 views
7

我試圖運行上手與Node.js的獲取茉莉花在服務器端

我使用grunt,並且grunt-jasmine-node在服務器端JavaScript的測試,但我不能讓它來運行我的測試。

它只是記錄

PS C:\開發\ NET \來源\ JSN>咕嚕運行 「jasmine_node」 任務 未定義

在0.001秒0試驗,0斷言,0失敗完成

完成,沒有錯誤。

這是我Gruntfile.js

module.exports = function(grunt) { 
    grunt.initConfig({ 
     pkg: grunt.file.readJSON('package.json'), 
     jasmine_node: { 
      specNameMatcher: 'spec', 
      projectRoot: '.', 
      requirejs: false, 
      forceExit: true, 
      jUnit: { 
       report: false, 
       savePath : "./build/reports/jasmine/", 
       useDotNotation: true, 
       consolidate: true 
      } 
     } 
    }); 

    grunt.loadNpmTasks('grunt-jasmine-node'); 
    grunt.registerTask('default', 'jasmine_node'); 
}; 

我的文件結構是這樣的:

enter image description here

那麼,我究竟做錯了什麼?

這就像stub.js文件甚至沒有加載,因爲它有一個console.log調用來測試。

+0

我不能幫你解決你的問題,但作爲替代方案,你可以嘗試Grunt團隊的Jasmine插件:https://github.com/gruntjs/grunt-contrib-jasmine。 – 2013-03-18 19:07:30

+0

grunt-contrib-jasmine在瀏覽器(PhantomJS)中運行測試。它不會幫助在節點上運行測試。 – johnmcase 2015-05-14 20:23:09

回答

6

或者:

  • 確保擴展您的JavaScript測試規範是.spec.js

或者

  • 更換配置選項specNameMatchermatchall: true
+1

同樣在這裏,我試圖在/specs/**/*.coffee中運行coffeescript測試,但我不管理。任何提示? – Edmondo1984 2013-11-20 15:39:57