Skip to content

Commit 74ede4f

Browse files
committed
Add a new instruction - "abort"
1 parent e946198 commit 74ede4f

File tree

7 files changed

+45
-9
lines changed

7 files changed

+45
-9
lines changed

Gruntfile.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,16 @@ module.exports = function (grunt) {
401401
force: true
402402
},
403403
commands: [
404-
{ wait: true}
404+
{wait: true}
405+
]
406+
},
407+
'abort': {
408+
options: {
409+
force: true
410+
},
411+
commands: [
412+
{abort: 'Stop.'},
413+
{file: 'aborted'}
405414
]
406415
}
407416
},

INSTRUCTIONS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ One of the instructions has to be present in every command. These properties are
3232
- [isNotSelected](#isnotselected)
3333
- [isNotVisible](#isnotvisible)
3434
- [isNotVisibleWithinViewport](#isnotvisiblewithinviewport)
35+
- [abort](#abort)
3536
- [file](#file)
3637

3738
#### setViewport
@@ -610,6 +611,11 @@ The input string should contain selector of the element to check.
610611
}
611612
```
612613

614+
## abort
615+
Type: `String`
616+
617+
Stops executing firther commands and fails current Grunt task with the specified message. It can be used to stop the tests at a specific point and investigate the situation in the web browser.
618+
613619
## file
614620
Type: `String`
615621

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ One of the [instructions] has to be present in every command. These properties a
270270
* [isNotSelected](INSTRUCTIONS.md#isnotselected)
271271
* [isNotVisible](INSTRUCTIONS.md#isnotvisible)
272272
* [isNotVisibleWithinViewport](INSTRUCTIONS.md#isnotvisiblewithinviewport)
273+
* [abort](INSTRUCTIONS.md#abort)
273274
* [file](INSTRUCTIONS.md#file)
274275

275276
#### options
@@ -496,6 +497,7 @@ your code using Grunt.
496497
497498
## Release History
498499
500+
* 2018-03-11 [v0.8.0] Add a new instruction - "abort"
499501
* 2018-03-01 [v0.7.0] Add optional automatic file numbering
500502
* 2018-02-28 [v0.6.0] Add the allRequired option to the hasClass instruction
501503
* 2018-02-26 [v0.5.0] Allow checking and setting various properties

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
"node": ">= 4"
2727
},
2828
"scripts": {
29-
"security": "test `node --version | cut -c 2` -ne 4 && nsp check || echo 'No vulnerabilities check possible on Node.js 4'",
30-
"test": "npm run security && grunt",
29+
"prepare": "test `node --version | cut -c 2` -ne 4 && nsp check || echo 'No vulnerabilities check possible on Node.js 4'",
30+
"test": "grunt",
3131
"coverage": "grunt instrument && GRUNT_HTML_DOM_SNAPSHOT_COVERAGE=1 grunt",
3232
"coveralls": "test `node --version | cut -c 2` -eq 8 && npm run coverage && grunt coveralls",
3333
"semantic-release": "semantic-release",
@@ -36,21 +36,21 @@
3636
"dependencies": {
3737
"mkdirp": "^0.5.1",
3838
"pad-left": "^2.1.0",
39-
"webdriverio": "^4.11.0"
39+
"webdriverio": "^4.12.0"
4040
},
4141
"devDependencies": {
42-
"grunt": "^1.0.1",
42+
"grunt": "^1.0.2",
4343
"grunt-contrib-clean": "^1.1.0",
4444
"grunt-contrib-connect": "^1.0.2",
4545
"grunt-contrib-nodeunit": "^1.0.0",
4646
"grunt-coveralls": "^1.0.1",
4747
"grunt-eslint": "^20.1.0",
4848
"grunt-istanbul": "^0.8.0",
4949
"grunt-selenium-standalone": "^1.0.1",
50-
"nsp": "^3.1.0",
50+
"nsp": "^3.2.1",
5151
"phantomjs-prebuilt": "^2.1.16",
52-
"semantic-release": "^12.4.1",
53-
"travis-deploy-once": "^4.3.4"
52+
"semantic-release": "^15.0.2",
53+
"travis-deploy-once": "^4.4.0"
5454
},
5555
"peerDependencies": {
5656
"grunt": ">=0.4.5"

tasks/html-dom-snapshot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const fs = require('fs'),
2121
'isEnabled', 'isExisting', 'isFocused', 'isSelected', 'isVisible',
2222
'isVisibleWithinViewport', 'isNotEnabled', 'isNotExisting',
2323
'isNotFocused', 'isNotSelected', 'isNotVisible',
24-
'isNotVisibleWithinViewport'
24+
'isNotVisibleWithinViewport', 'abort'
2525
].map(function (instruction) {
2626
return require('./instructions/' + instruction);
2727
});

tasks/instructions/abort.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
module.exports = {
4+
detect: function (command) {
5+
return !!command.abort;
6+
},
7+
8+
perform: function (grunt, target, client, command) {
9+
throw new Error('Aborted: "' + command.abort +
10+
'" in the target "' + target + '".\n' +
11+
JSON.stringify(command));
12+
}
13+
};

test/test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,11 @@ exports['html-dom-snapshot'] = {
9191
const pages = readPages('scenario1.html');
9292
test.equal(pages.expected, pages.actual, 'scenario1.html');
9393
test.done();
94+
},
95+
96+
'abort': function (test) {
97+
const snapshot = fs.existsSync('test/snapshots/abort.html');
98+
test.ok(!snapshot, 'abort.html');
99+
test.done();
94100
}
95101
};

0 commit comments

Comments
 (0)