grunt-html-snapshots 1.0.2 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +2 -0
- package/.eslintrc.json +16 -0
- package/.github/workflows/verify.yml +29 -0
- package/Gruntfile.js +9 -23
- package/{LICENSE-MIT → LICENSE.md} +1 -1
- package/README.md +3 -6
- package/package.json +10 -9
- package/tasks/html_snapshots.js +11 -15
- package/test/helpers/options.js +5 -5
- package/test/html_snapshots_target1.js +17 -29
- package/test/html_snapshots_target2.js +17 -29
- package/test/html_snapshots_test.js +26 -31
- package/test/utils.js +14 -0
- package/.jshintrc +0 -13
- package/.travis.yml +0 -6
package/.eslintignore
ADDED
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Verify
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: [ master ]
|
|
5
|
+
pull_request:
|
|
6
|
+
branches: [ master ]
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
verify:
|
|
10
|
+
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
strategy:
|
|
14
|
+
matrix:
|
|
15
|
+
node-version: [14.x, 16.x]
|
|
16
|
+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v3
|
|
20
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
21
|
+
uses: actions/setup-node@v3.0.0
|
|
22
|
+
with:
|
|
23
|
+
node-version: ${{ matrix.node-version }}
|
|
24
|
+
- run: npm ci
|
|
25
|
+
- name: Lint
|
|
26
|
+
run: npm run lint
|
|
27
|
+
- name: Test
|
|
28
|
+
if: ${{ success() }}
|
|
29
|
+
run: npm test
|
package/Gruntfile.js
CHANGED
|
@@ -2,27 +2,14 @@
|
|
|
2
2
|
* grunt-html-snapshots
|
|
3
3
|
* https://github.com/localnerve/grunt-html-snapshots
|
|
4
4
|
*
|
|
5
|
-
* Copyright (c) 2013
|
|
5
|
+
* Copyright (c) 2013 - 2022 Alex Grant
|
|
6
6
|
* Licensed under the MIT license.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
module.exports = function(grunt) {
|
|
9
|
+
module.exports = function (grunt) {
|
|
12
10
|
|
|
13
11
|
// Project configuration.
|
|
14
12
|
grunt.initConfig({
|
|
15
|
-
jshint: {
|
|
16
|
-
all: [
|
|
17
|
-
'Gruntfile.js',
|
|
18
|
-
'tasks/*.js',
|
|
19
|
-
'<%= nodeunit.tests %>',
|
|
20
|
-
],
|
|
21
|
-
options: {
|
|
22
|
-
jshintrc: '.jshintrc',
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
|
|
26
13
|
// Before generating any new files, remove any previously-created files.
|
|
27
14
|
clean: {
|
|
28
15
|
tests: ['tmp'],
|
|
@@ -74,23 +61,22 @@ module.exports = function(grunt) {
|
|
|
74
61
|
grunt.loadTasks('tasks');
|
|
75
62
|
|
|
76
63
|
// These plugins provide necessary tasks.
|
|
77
|
-
grunt.loadNpmTasks('grunt-contrib-jshint');
|
|
78
64
|
grunt.loadNpmTasks('grunt-contrib-clean');
|
|
79
65
|
grunt.loadNpmTasks('grunt-contrib-nodeunit');
|
|
80
66
|
|
|
81
67
|
// Register the test server
|
|
82
68
|
grunt.registerTask('test_server1', 'serve the test files', function(){
|
|
83
|
-
|
|
84
|
-
|
|
69
|
+
const options = this.options();
|
|
70
|
+
const server = require('./test/server');
|
|
85
71
|
server.start('./test/server', options.port);
|
|
86
72
|
grunt.log.writeln("running test server on port "+options.port);
|
|
87
73
|
grunt.log.ok();
|
|
88
74
|
});
|
|
89
75
|
|
|
90
|
-
grunt.registerTask('html_snapshots_options', 'prepare options for html_snapshots', function()
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
optionsHelper.detector(
|
|
76
|
+
grunt.registerTask('html_snapshots_options', 'prepare options for html_snapshots', function(){
|
|
77
|
+
const optionsHelper = require("./test/helpers/options");
|
|
78
|
+
const done = this.async();
|
|
79
|
+
optionsHelper.detector(globalPhantom => {
|
|
94
80
|
if (globalPhantom) {
|
|
95
81
|
var htmlSnapshots = grunt.config.get("html_snapshots");
|
|
96
82
|
htmlSnapshots.options.phantomjs = "phantomjs";
|
|
@@ -106,6 +92,6 @@ module.exports = function(grunt) {
|
|
|
106
92
|
grunt.registerTask('target2', ['clean', 'html_snapshots_options', 'html_snapshots:target2', 'nodeunit:target2']);
|
|
107
93
|
|
|
108
94
|
// By default, lint and run all tests.
|
|
109
|
-
grunt.registerTask('default', ['
|
|
95
|
+
grunt.registerTask('default', ['test']);
|
|
110
96
|
|
|
111
97
|
};
|
package/README.md
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
# grunt-html-snapshots
|
|
2
2
|
|
|
3
|
-
[](https://greenkeeper.io/)
|
|
4
|
-
|
|
5
3
|
[](http://badge.fury.io/js/grunt-html-snapshots)
|
|
6
|
-
|
|
4
|
+

|
|
7
5
|
[](https://david-dm.org/localnerve/grunt-html-snapshots)
|
|
8
|
-
[](https://david-dm.org/localnerve/grunt-html-snapshots#info=devDependencies)
|
|
9
|
-
[](https://david-dm.org/localnerve/grunt-html-snapshots#info=peerDependencies)
|
|
10
6
|
|
|
11
7
|
> The grunt task for [html-snapshots](http://github.com/localnerve/html-snapshots)
|
|
12
8
|
|
|
13
9
|
## Getting Started
|
|
14
|
-
This plugin requires Grunt `>=0.
|
|
10
|
+
This plugin requires Grunt `>=1.0.0`
|
|
11
|
+
*To use an older Grunt, use this library at tag `#v1.0.2`*
|
|
15
12
|
|
|
16
13
|
If you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
|
|
17
14
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "grunt-html-snapshots",
|
|
3
3
|
"description": "The grunt task for html-snapshots",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.1",
|
|
5
5
|
"homepage": "https://github.com/localnerve/grunt-html-snapshots",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Alex Grant",
|
|
@@ -18,22 +18,23 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"main": "Gruntfile.js",
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
21
|
+
"node": ">= 14"
|
|
22
22
|
},
|
|
23
23
|
"scripts": {
|
|
24
|
-
"test": "grunt test"
|
|
24
|
+
"test": "grunt test",
|
|
25
|
+
"lint": "eslint ."
|
|
25
26
|
},
|
|
26
27
|
"dependencies": {
|
|
27
|
-
"html-snapshots": "
|
|
28
|
+
"html-snapshots": "^0.18.1"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
|
-
"
|
|
31
|
-
"grunt-contrib-clean": "^
|
|
32
|
-
"grunt-contrib-nodeunit": "^
|
|
33
|
-
"grunt": ">=0.
|
|
31
|
+
"eslint": "^8.12.0",
|
|
32
|
+
"grunt-contrib-clean": "^2.0.1",
|
|
33
|
+
"grunt-contrib-nodeunit": "^4.0.0",
|
|
34
|
+
"grunt": ">=1.0.0"
|
|
34
35
|
},
|
|
35
36
|
"peerDependencies": {
|
|
36
|
-
"grunt": ">=0.
|
|
37
|
+
"grunt": ">=1.0.0"
|
|
37
38
|
},
|
|
38
39
|
"keywords": [
|
|
39
40
|
"SEO",
|
package/tasks/html_snapshots.js
CHANGED
|
@@ -2,45 +2,41 @@
|
|
|
2
2
|
* grunt-html-snapshots
|
|
3
3
|
* https://github.com/localnerve/grunt-html-snapshots
|
|
4
4
|
*
|
|
5
|
-
* Copyright (c) 2013 -
|
|
5
|
+
* Copyright (c) 2013 - 2022, LocalNerve, Alex Grant
|
|
6
6
|
* Licensed under the MIT license.
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var html_snapshots = require('html-snapshots');
|
|
11
|
-
|
|
12
|
-
grunt.registerMultiTask('html_snapshots', 'Generate html snapshots.',
|
|
13
|
-
function () {
|
|
8
|
+
const html_snapshots = require('html-snapshots');
|
|
14
9
|
|
|
10
|
+
module.exports = function (grunt) {
|
|
11
|
+
grunt.registerMultiTask('html_snapshots', 'Generate html snapshots.', function () {
|
|
15
12
|
// Merge task-specific and/or target-specific options with these defaults.
|
|
16
|
-
|
|
13
|
+
const options = this.options({
|
|
17
14
|
force: false
|
|
18
15
|
});
|
|
19
16
|
|
|
20
17
|
// Report html_snapshot errors but dont fail the task
|
|
21
|
-
|
|
18
|
+
const force = options.force;
|
|
22
19
|
delete options.force;
|
|
23
20
|
|
|
24
21
|
grunt.verbose.writeflags(options, 'html_snapshots options');
|
|
25
22
|
|
|
26
23
|
// Setup for async
|
|
27
|
-
|
|
24
|
+
const done = this.async();
|
|
28
25
|
|
|
29
26
|
// Take the snapshots
|
|
30
27
|
html_snapshots.run(options)
|
|
31
|
-
.then(
|
|
28
|
+
.then(() => {
|
|
32
29
|
grunt.log.ok();
|
|
33
30
|
})
|
|
34
|
-
.catch(
|
|
31
|
+
.catch(err => {
|
|
35
32
|
grunt.log.error('html_snapshots failed');
|
|
36
33
|
if (force) {
|
|
37
|
-
grunt.log.error(
|
|
34
|
+
grunt.log.error(err);
|
|
38
35
|
}
|
|
39
36
|
return err;
|
|
40
37
|
})
|
|
41
|
-
.then(
|
|
38
|
+
.then(err => {
|
|
42
39
|
done(force ? undefined : err);
|
|
43
40
|
});
|
|
44
41
|
});
|
|
45
|
-
|
|
46
42
|
};
|
package/test/helpers/options.js
CHANGED
|
@@ -8,22 +8,22 @@
|
|
|
8
8
|
* In some test environments (travis), local phantomjs will not install if a global is found.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
const spawn = require("child_process").spawn;
|
|
12
12
|
|
|
13
13
|
module.exports = {
|
|
14
14
|
|
|
15
15
|
// for now, callback is passed true if global phantomjs should be used
|
|
16
|
-
detector:
|
|
16
|
+
detector: callback => {
|
|
17
17
|
// try to run phantom globally
|
|
18
|
-
|
|
18
|
+
const cp = spawn("phantomjs", ["--version"]);
|
|
19
19
|
|
|
20
20
|
// if it fails, use local per the defaults
|
|
21
|
-
cp.on("error",
|
|
21
|
+
cp.on("error", () => {
|
|
22
22
|
callback(false);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
// if it succeeds, use the global
|
|
26
|
-
cp.on("exit",
|
|
26
|
+
cp.on("exit", code => {
|
|
27
27
|
if (code === 0) {
|
|
28
28
|
callback(true);
|
|
29
29
|
}
|
|
@@ -1,41 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
======== A Handy Little Nodeunit Reference ========
|
|
8
|
-
https://github.com/caolan/nodeunit
|
|
9
|
-
|
|
10
|
-
Test methods:
|
|
11
|
-
test.expect(numAssertions)
|
|
12
|
-
test.done()
|
|
13
|
-
Test assertions:
|
|
14
|
-
test.ok(value, [message])
|
|
15
|
-
test.equal(actual, expected, [message])
|
|
16
|
-
test.notEqual(actual, expected, [message])
|
|
17
|
-
test.deepEqual(actual, expected, [message])
|
|
18
|
-
test.notDeepEqual(actual, expected, [message])
|
|
19
|
-
test.strictEqual(actual, expected, [message])
|
|
20
|
-
test.notStrictEqual(actual, expected, [message])
|
|
21
|
-
test.throws(block, [error], [message])
|
|
22
|
-
test.doesNotThrow(block, [error], [message])
|
|
23
|
-
test.ifError(value)
|
|
24
|
-
*/
|
|
1
|
+
/**
|
|
2
|
+
* tests, target1
|
|
3
|
+
*/
|
|
4
|
+
/* global Promise */
|
|
5
|
+
const grunt = require('grunt');
|
|
6
|
+
const { pathExists } = require('./utils');
|
|
25
7
|
|
|
26
8
|
exports.html_snapshots = {
|
|
27
|
-
setUp:
|
|
9
|
+
setUp: done => {
|
|
28
10
|
// setup here if necessary
|
|
29
11
|
done();
|
|
30
12
|
},
|
|
31
13
|
|
|
32
|
-
target1:
|
|
14
|
+
target1: test => {
|
|
33
15
|
test.expect(3);
|
|
34
16
|
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
const results = [];
|
|
18
|
+
|
|
19
|
+
grunt.file.read('test/expected/target1').split('\n').forEach(line => {
|
|
20
|
+
results.push(pathExists(line).then(exists => {
|
|
21
|
+
test.equal(true, exists, `${line} should exist`);
|
|
22
|
+
}));
|
|
37
23
|
});
|
|
38
24
|
|
|
39
|
-
|
|
25
|
+
Promise.all(results).finally(()=> {
|
|
26
|
+
test.done();
|
|
27
|
+
})
|
|
40
28
|
}
|
|
41
29
|
};
|
|
@@ -1,41 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
======== A Handy Little Nodeunit Reference ========
|
|
8
|
-
https://github.com/caolan/nodeunit
|
|
9
|
-
|
|
10
|
-
Test methods:
|
|
11
|
-
test.expect(numAssertions)
|
|
12
|
-
test.done()
|
|
13
|
-
Test assertions:
|
|
14
|
-
test.ok(value, [message])
|
|
15
|
-
test.equal(actual, expected, [message])
|
|
16
|
-
test.notEqual(actual, expected, [message])
|
|
17
|
-
test.deepEqual(actual, expected, [message])
|
|
18
|
-
test.notDeepEqual(actual, expected, [message])
|
|
19
|
-
test.strictEqual(actual, expected, [message])
|
|
20
|
-
test.notStrictEqual(actual, expected, [message])
|
|
21
|
-
test.throws(block, [error], [message])
|
|
22
|
-
test.doesNotThrow(block, [error], [message])
|
|
23
|
-
test.ifError(value)
|
|
24
|
-
*/
|
|
1
|
+
/**
|
|
2
|
+
* tests, target2
|
|
3
|
+
*/
|
|
4
|
+
/* global Promise */
|
|
5
|
+
const grunt = require('grunt');
|
|
6
|
+
const { pathExists } = require('./utils');
|
|
25
7
|
|
|
26
8
|
exports.html_snapshots = {
|
|
27
|
-
setUp:
|
|
9
|
+
setUp: done => {
|
|
28
10
|
// setup here if necessary
|
|
29
11
|
done();
|
|
30
12
|
},
|
|
31
13
|
|
|
32
|
-
target2:
|
|
14
|
+
target2: test => {
|
|
33
15
|
test.expect(3);
|
|
34
16
|
|
|
35
|
-
|
|
36
|
-
|
|
17
|
+
const results = [];
|
|
18
|
+
|
|
19
|
+
grunt.file.read('test/expected/target2').split('\n').forEach(line => {
|
|
20
|
+
results.push(pathExists(line).then(exists => {
|
|
21
|
+
test.equal(false, exists, `${line} should not exist`);
|
|
22
|
+
}));
|
|
37
23
|
});
|
|
38
24
|
|
|
39
|
-
|
|
25
|
+
Promise.all(results).finally(() => {
|
|
26
|
+
test.done();
|
|
27
|
+
});
|
|
40
28
|
}
|
|
41
29
|
};
|
|
@@ -1,30 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
https://github.com/caolan/nodeunit
|
|
9
|
-
|
|
10
|
-
Test methods:
|
|
11
|
-
test.expect(numAssertions)
|
|
12
|
-
test.done()
|
|
13
|
-
Test assertions:
|
|
14
|
-
test.ok(value, [message])
|
|
15
|
-
test.equal(actual, expected, [message])
|
|
16
|
-
test.notEqual(actual, expected, [message])
|
|
17
|
-
test.deepEqual(actual, expected, [message])
|
|
18
|
-
test.notDeepEqual(actual, expected, [message])
|
|
19
|
-
test.strictEqual(actual, expected, [message])
|
|
20
|
-
test.notStrictEqual(actual, expected, [message])
|
|
21
|
-
test.throws(block, [error], [message])
|
|
22
|
-
test.doesNotThrow(block, [error], [message])
|
|
23
|
-
test.ifError(value)
|
|
24
|
-
*/
|
|
1
|
+
/**
|
|
2
|
+
* Test the task
|
|
3
|
+
*/
|
|
4
|
+
/* global Promise */
|
|
5
|
+
|
|
6
|
+
const grunt = require('grunt');
|
|
7
|
+
const { pathExists } = require('./utils');
|
|
25
8
|
|
|
26
9
|
exports.html_snapshots = {
|
|
27
|
-
setUp: function(done) {
|
|
10
|
+
setUp: function (done) {
|
|
28
11
|
// setup here if necessary
|
|
29
12
|
done();
|
|
30
13
|
},
|
|
@@ -32,20 +15,32 @@ exports.html_snapshots = {
|
|
|
32
15
|
target1: function(test) {
|
|
33
16
|
test.expect(3);
|
|
34
17
|
|
|
35
|
-
|
|
36
|
-
|
|
18
|
+
const results = [];
|
|
19
|
+
|
|
20
|
+
grunt.file.read('test/expected/target1').split('\n').forEach(line => {
|
|
21
|
+
results.push(pathExists(line).then(exists => {
|
|
22
|
+
test.equal(true, exists, `${line} should exist`);
|
|
23
|
+
}));
|
|
37
24
|
});
|
|
38
25
|
|
|
39
|
-
|
|
26
|
+
Promise.all(results).finally(() => {
|
|
27
|
+
test.done();
|
|
28
|
+
});
|
|
40
29
|
},
|
|
41
30
|
|
|
42
31
|
target2: function(test) {
|
|
43
32
|
test.expect(3);
|
|
44
33
|
|
|
45
|
-
|
|
46
|
-
|
|
34
|
+
const results = [];
|
|
35
|
+
|
|
36
|
+
grunt.file.read('test/expected/target2').split('\n').forEach(line => {
|
|
37
|
+
results.push(pathExists(line).then(exists => {
|
|
38
|
+
test.equal(false, exists, `${line} should not exist`);
|
|
39
|
+
}));
|
|
47
40
|
});
|
|
48
41
|
|
|
49
|
-
|
|
42
|
+
Promise.all(results).finally(() => {
|
|
43
|
+
test.done();
|
|
44
|
+
});
|
|
50
45
|
}
|
|
51
46
|
};
|
package/test/utils.js
ADDED
package/.jshintrc
DELETED