cleanup webdriver jasmine task
Thomas Aylott committed
Nov 6, 2013 at 15:16 UTC
1368b2959687adfadc06dd21f19d05ea716480a3
1 file changed
+16
-6
grunt/tasks/webdriver-jasmine.js
+16
-6
@@ -2,8 +2,10 @@ var grunt = require("grunt");
2
var wd = require('wd');
3
4
module.exports = function(){
5
+ var config = this.data;
6
var taskSucceeded = this.async();
6
- var browser = wd.promiseChainRemote(this.data.webdriver.remote);
7
+ grunt.verbose.write('webdriver remote', JSON.stringify(config.webdriver.remote));
8
+ var browser = wd.promiseChainRemote(config.webdriver.remote);
9
10
browser.on('status', function(info) {
11
grunt.verbose.writeln(info);
@@ -14,13 +16,21 @@ module.exports = function(){
16
});
17
18
browser
17
- .init(this.data.browser)
18
- .get(this.data.url)
19
+ .init(config.browser || {})
20
+ .get(config.url)
21
.then(function(){return browser;})
22
.then(getJSReport)
21
- .then(this.data.onComplete && this.data.onComplete.bind(browser), this.data.onError && this.data.onError.bind(browser))
22
- .fin(browser.quit.bind(browser))
23
- .done(taskSucceeded.bind(null,true), taskSucceeded.bind(null,false))
23
+ .then(config.onComplete && config.onComplete.bind(browser), config.onError && config.onError.bind(browser))
24
+ .fail(grunt.verbose.writeln.bind(grunt.verbose))
25
+ .fin(function(){
26
+ if (grunt.option('webdriver-keep-open')) return;
27
+ grunt.verbose.writeln('Closing the browser window. To keep it open, pass the --webdriver-keep-open flag to grunt.');
28
+ return browser.quit();
29
+ })
30
+ .done(
31
+ taskSucceeded.bind(null,true),
32
+ taskSucceeded.bind(null,false)
33
+ )
34
;
35
}
36