There is a fork of the Grunt shell called Grunt-shell-spawn ( Github Repo ) that allows background processes to be run asynchronously. This works very well with running the selenium webdriver server, helping to automate the transporter testing process. There are several grunt plugins specifically for starting the webdriver server, but from my experience they all have small errors that cause errors after completing the tests or require you to check the flagkeepAlive: true, which means that it will not kill the forced process of the webdriver server you ctrl + c or close and reopen the command line, which can cause many problems when developers use functional tests and continuous integration (CI) servers. Grunt-shell-spawn has the ability to kill a process, as you can see at the end of my “test” task, which is really invaluable for maintaining consistency and ease of use.
'use strict';
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-shell-spawn');
grunt.loadNpmTasks('grunt-protractor-runner');
var path = require('path');
grunt.initConfig({
...
...
...
shell: {
updateserver: {
options: {
stdout: true
},
command: "node " + path.resolve('node_modules/protractor/bin/webdriver-manager') + ' update --standalone --chrome'
},
startserver: {
options: {
stdout:false,
stdin: false,
stderr: false,
async:true
},
command: 'node ' + path.resolve('node_modules/protractor/bin/webdriver-manager') + ' start --standalone'
},
});
grunt.registerTask('test',[
'shell:updateserver',
'shell:startserver',
'protractor:e2e',
'shell:startserver:kill'
]);
sonhu source
share