Skip to content

Commit 8a76a35

Browse files
committed
feat: Introduce a hangOnError option to keep the browser running in case of failure to be able to investigate the problem
1 parent c42f663 commit 8a76a35

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ Default options support the most usual usage scenario:
9191
fileNumbering: false,
9292
fileNumberDigits: 3,
9393
fileNumberSeparator: '.',
94+
hangOnError: false,
9495
force: false
9596
},
9697
'google': {
@@ -202,6 +203,12 @@ Default value: '.'
202203

203204
The character to put between the file number and the file name.
204205

206+
### hangOnError
207+
Type: `Boolean`
208+
Default value: false
209+
210+
If set to `true`, it will not abort the process in case of a failure. It is useful, if you want to investigate the situation on the screen right after an error occurred. If you encounter an error flip this flag and re-run the failing scenario. Once you are finished terminate the process or interrupt it by Ctrl+C.
211+
205212
#### force
206213
Type: `Boolean`
207214
Default value: false
@@ -590,6 +597,7 @@ your code using Grunt.
590597
591598
## Release History
592599
600+
* 2019-07-08 [v2.2.0] Optionally hang the browser in case of failure to be able to inspect the web page in developer tools
593601
* 2018-11-26 [v2.0.0] Use headless Chrome instead of PhantomJS by default, introduce conditional if-then-else instructions
594602
* 2018-05-14 [v1.3.0] Allow saving snapshots to sub-directories, file numbering per-directory, add `scroll` instruction
595603
* 2018-05-11 [v1.2.0] Introduce delay after every instruction to be able to visually follow the actions when debugging
@@ -634,6 +642,7 @@ Licensed under the MIT license.
634642
[grunt-reg-viz]: https://github.com/prantlf/grunt-reg-viz
635643
[grunt-selenium-standalone]: https://github.com/zs-zs/grunt-selenium-standalone
636644
[keyboard key identifiers]: https://w3c.github.io/webdriver/webdriver-spec.html#keyboard-actions
645+
[v2.2.0]: https://github.com/prantlf/grunt-html-dom-snapshot/releases/tag/v2.2.0
637646
[v2.0.0]: https://github.com/prantlf/grunt-html-dom-snapshot/releases/tag/v2.0.0
638647
[v1.3.0]: https://github.com/prantlf/grunt-html-dom-snapshot/releases/tag/v1.3.0
639648
[v1.2.0]: https://github.com/prantlf/grunt-html-dom-snapshot/releases/tag/v1.2.0

tasks/html-dom-snapshot.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ module.exports = grunt => {
5353
fileNumbering: false,
5454
fileNumberDigits: 3,
5555
fileNumberSeparator: '.',
56+
hangOnError: false,
5657
force: false
5758
})
5859
const target = this.target
@@ -112,16 +113,21 @@ module.exports = grunt => {
112113
failed = true
113114
grunt.verbose.error(error.stack)
114115
grunt.log.error(error)
115-
return stop(false)
116+
if (!options.hangOnError) {
117+
return stop(false)
118+
}
116119
})
117120
.then(() => {
118121
if (failed) {
119-
const warn = options.force ? grunt.log.warn : grunt.fail.warn
122+
const warn = options.force || options.hangOnError ? grunt.log.warn : grunt.fail.warn
120123
warn('Taking snapshots failed.')
124+
if (options.hangOnError) {
125+
warn('Letting the browser run for your investigation.\nTerminate this process or interrupt it by Ctrl+C, once you are finished.')
126+
}
121127
}
122128
})
123129
.then(() => {
124-
if (!failed) {
130+
if (!(failed && options.hangOnError)) {
125131
done()
126132
}
127133
})

0 commit comments

Comments
 (0)