I'm trying to use grunt to run Xvfb and my protractor tests, but when I executed my Task protractor-xvfb, I've got this return:
Running tasks: protractor-xvfb Warning: Task "protractor-xvfb" not found. Use --force to continue.
Aborted due to warnings.
My 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.');
});
}
When I executed my Task test, it is sucessful and I've got this return:
Running tasks: test
Running "test" task Lorem ipsum dolor sit amet.
Done, without errors.
OBS: My tests with protractor without grunt is working fine. Return:
Finished in 24.753 seconds
9 tests, 5 assertions, 0 failures
OBS2: I'm following this example: Running Xvfb from Grunt
I solved my problem !
First of all My Gruntfile.js wasn't on my project root directory and I need it in project root directory close to package.json to load my plugins to run those tests. When my Gruntfile.js was on the wrong path when I added those plugin to load my test fails:
Fail message:
I removed all my grunt stuff that I had install and installed again.
With my Gruntfile in the right path I could be able to load my plugins and run my tests with Grunt + Xvfb + Protractor.