2015-06-12 25 views
2

我試圖用咕嚕運行的Xvfb和我的量角器的測試,但是當我執行我的任務量角器-xvfb的,我有這樣的回報:步兵+量角器 - 任務「殼:xvfb的」未找到

正在運行的任務:量角器-xvfb警告:任務「量角器-xvfb」未找到 。使用--force繼續。

由於警告而中止。

我Gruntfile.js:

module.exports = function(grunt) { 
 

 

 
    grunt.initConfig({ 
 
     protractor: { 
 
      options: { 
 
       keepAlive: true, 
 
       configFile: "protractor.conf.js" 
 
      }, 
 
      run: {} 
 
     }, 
 

 
     shell: { 
 
      xvfb: { 
 
       command: 'Xvfb :99 -ac -screen 0 1600x1200x24', 
 
       options: { 
 
        async: true 
 
       } 
 
      } 
 
     }, 
 
     env: { 
 
      xvfb: { 
 
       DISPLAY: ':99' 
 
      } 
 
     } 
 

 
}); 
 

 

 
    grunt.registerTask('protractor-xvfb',[ 
 
     'shell:xvfb', 
 
     'env:xvfb', 
 
     'protractor:run', 
 
     'shell:xvfb:kill' 
 
     ]); 
 

 
// assim funciona 
 
    grunt.registerTask('test', 'Test task.', function() { 
 
     grunt.log.writeln('Lorem ipsum dolor sit amet.'); 
 
    }); 
 

 
}

當我執行我的任務測試中,它是SUCESSFUL和我有這個回報:

運行的任務:test

正在運行「測試」任務Lorem ipsum dolor坐amet。

完成,沒有錯誤。

OBS:我用沒有咕嚕聲的量角器測試工作正常。返回:

完成了24.753秒

9測試,5個斷言,0失敗

OBS2:我下面這個例子:Running Xvfb from Grunt

回答

1

我解決了我的問題!

首先我的Gruntfile.js不在我的項目根目錄下,我需要它在項目根目錄中靠近package.json加載我的插件來運行這些測試。當我的Gruntfile.js是在錯誤的道路上,當我說這些插件加載我的測試失敗:

grunt.loadNpmTasks('grunt-shell-spawn'); 
grunt.loadNpmTasks('grunt-env'); 
grunt.loadNpmTasks('grunt-protractor-runner'); 

失敗消息:

Registering "grunt-shell-spawn" local Npm module tasks. 
>> Local Npm module "grunt-shell-spawn" not found. Is it installed? 

Registering "grunt-env" local Npm module tasks. 
>> Local Npm module "grunt-env" not found. Is it installed? 

Registering "grunt-protractor-runner" local Npm module tasks. 
>> Local Npm module "grunt-protractor-runner" not found. Is it installed? 
Loading "Gruntfile.js" tasks...OK 

我刪除了我所有的咕嚕東西,我不得不安裝和安裝再次。

隨着我的Gruntfile在正確的路徑,我可以加載我的插件,並運行Grunt + Xvfb +量角器我的測試。

0

我不知道,如果這是核心問題,但是您已將shell.xvfb.command設置爲包含代碼中的字符串的數組,而作爲示例,您鏈接的只有一個字符串。

+0

我編輯了我的命令,但仍然無法正常工作。 – Rfranca

+0

我用這個解決方案解決了我的問題http://stackoverflow.com/questions/30985531/grunt-protractor-task-shellxvfb-not-found-solved – Rfranca