html-snapshots 0.18.3 → 1.0.0
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/.eslintrc.json +4 -5
- package/.github/workflows/verify.yml +2 -2
- package/HISTORY.md +42 -0
- package/README.md +109 -256
- package/examples/README.md +149 -0
- package/examples/custom/myFilter.js +2 -2
- package/examples/custom/package-lock.json +2021 -5
- package/examples/custom/package.json +1 -1
- package/examples/custom/snapshot.js +8 -10
- package/examples/debug-phantomjs/package-lock.json +6 -6
- package/examples/debug-phantomjs/package.json +1 -1
- package/examples/debug-phantomjs/snapshot.js +13 -14
- package/examples/debug-puppeteer/README.md +18 -0
- package/examples/debug-puppeteer/package-lock.json +2804 -0
- package/examples/debug-puppeteer/package.json +12 -0
- package/examples/debug-puppeteer/snapshot.js +30 -0
- package/examples/html5rocks/package-lock.json +1306 -5
- package/examples/html5rocks/package.json +1 -1
- package/examples/html5rocks/snapshot.js +14 -23
- package/examples/process-limit/package-lock.json +1306 -5
- package/examples/process-limit/package.json +1 -1
- package/examples/process-limit/snapshot.js +8 -10
- package/examples/simple-promise/package-lock.json +1306 -5
- package/examples/simple-promise/package.json +1 -1
- package/examples/simple-promise/snapshot.js +6 -8
- package/examples/sitemap-index/package-lock.json +1306 -5
- package/examples/sitemap-index/package.json +1 -1
- package/examples/sitemap-index/snapshot.js +6 -6
- package/examples/utils/index.js +2 -4
- package/examples/verbose/package-lock.json +1306 -5
- package/examples/verbose/package.json +1 -1
- package/examples/verbose/snapshot.js +12 -14
- package/lib/async/index.js +0 -1
- package/lib/common/index.js +1 -1
- package/lib/common/sitemap/index.js +16 -0
- package/lib/common/sitemap/sitemap-collection.js +94 -0
- package/lib/common/sitemap/sitemap-index.js +68 -0
- package/lib/common/{sitemap.js → sitemap/sitemap.js} +68 -57
- package/lib/html-snapshots.js +87 -5
- package/lib/input-generators/_base.js +7 -1
- package/lib/input-generators/array.js +0 -1
- package/lib/input-generators/robots.js +98 -58
- package/lib/input-generators/sitemap-index.js +3 -124
- package/lib/input-generators/sitemap.js +3 -7
- package/lib/input-generators/textfile.js +2 -6
- package/lib/puppeteer/index.js +98 -0
- package/lib/puppeteer/removeScripts.js +8 -0
- package/package.json +9 -4
- package/test/helpers/options.js +4 -2
- package/test/mocha/browsers/puppeteer.js +106 -0
- package/test/mocha/browsers/server/index.html +9 -0
- package/test/mocha/browsers/test.js +11 -0
- package/test/mocha/html-snapshots/basics.js +60 -47
- package/test/mocha/html-snapshots/phantomjs-options.js +54 -60
- package/test/mocha/html-snapshots/process-limit.js +126 -120
- package/test/mocha/html-snapshots/puppeteer.js +47 -0
- package/test/mocha/html-snapshots/robots.js +156 -121
- package/test/mocha/html-snapshots/server/public/page-sitemap.xml +16 -0
- package/test/mocha/html-snapshots/server/test_robots.txt +13 -0
- package/test/mocha/html-snapshots/server/test_robots_sitemap.txt +15 -0
- package/test/mocha/html-snapshots/server/test_robots_sitemap.xml +22 -0
- package/test/mocha/html-snapshots/sitemap-index.js +100 -90
- package/test/mocha/html-snapshots/sitemap.js +75 -31
- package/test/mocha/html-snapshots/snapshot-scripts.js +150 -145
- package/test/mocha/html-snapshots/test.js +23 -14
- package/test/mocha/html-snapshots/test_robots.txt +0 -2
- package/test/mocha/html-snapshots/use-jquery.js +65 -64
- package/test/mocha/html-snapshots/utils.js +29 -30
- package/test/mocha/input-generators/server/test_robots.txt +0 -2
- package/test/mocha/input-generators/server/test_robots_bad.txt +0 -2
- package/test/mocha/input-generators/server/test_robots_sitemap.txt +17 -0
- package/test/mocha/input-generators/server/test_robots_sitemap_bad.txt +17 -0
- package/test/mocha/input-generators/server/test_robots_sitemap_multi.txt +18 -0
- package/test/mocha/input-generators/server/test_sitemap_index_empty.xml +3 -0
- package/test/mocha/input-generators/server/test_sitemap_index_malformed.xml +2 -0
- package/test/mocha/input-generators/sitemap-index.js +65 -9
- package/test/mocha/input-generators/test.js +276 -280
- package/test/mocha/input-generators/test_robots.txt +0 -2
- package/test/mocha/input-generators/test_robots_bad.txt +0 -2
- package/test/mocha/input-generators/test_robots_sitemap.txt +17 -0
- package/test/mocha/input-generators/test_robots_sitemap_bad.txt +17 -0
- package/test/mocha/input-generators/test_robots_sitemap_multi.txt +18 -0
- package/lib/common/node.js +0 -26
- package/test/mocha/common/node.js +0 -100
|
@@ -4,52 +4,96 @@
|
|
|
4
4
|
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
5
|
*/
|
|
6
6
|
/* global it */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
const assert = require("assert");
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const _ = require("lodash");
|
|
10
|
+
const optHelp = require("../../helpers/options");
|
|
11
|
+
const ss = require("../../../lib/html-snapshots");
|
|
12
|
+
const utils = require("./utils");
|
|
13
13
|
|
|
14
14
|
// missing destructuring, will write postcard...
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const {
|
|
16
|
+
outputDir,
|
|
17
|
+
cleanup,
|
|
18
|
+
cleanupError,
|
|
19
|
+
cleanupSuccess,
|
|
20
|
+
unexpectedSuccess,
|
|
21
|
+
testSuccess,
|
|
22
|
+
checkActualFiles
|
|
23
|
+
} = utils;
|
|
18
24
|
|
|
19
25
|
// Sitemap constants
|
|
20
|
-
|
|
21
|
-
|
|
26
|
+
const inputFile = path.join(__dirname, "./test_sitemap.xml");
|
|
27
|
+
const urls = 3; // must match public/page_sitemap.xml
|
|
22
28
|
|
|
23
29
|
function sitemapTests (options) {
|
|
24
|
-
|
|
30
|
+
const {
|
|
31
|
+
port,
|
|
32
|
+
browsers
|
|
33
|
+
} = options;
|
|
25
34
|
|
|
26
35
|
return function () {
|
|
27
|
-
|
|
28
|
-
|
|
36
|
+
function createOptions(newOptions) {
|
|
37
|
+
const defaultOptions = {
|
|
29
38
|
input: "sitemap",
|
|
30
|
-
source:
|
|
31
|
-
port: port,
|
|
39
|
+
source: `http://localhost:${port}/index.html`,
|
|
32
40
|
selector: "#dynamic-content",
|
|
33
|
-
outputDir: outputDir,
|
|
34
41
|
outputDirClean: true,
|
|
35
|
-
timeout:
|
|
42
|
+
timeout: 4000,
|
|
43
|
+
outputDir,
|
|
44
|
+
port
|
|
36
45
|
};
|
|
37
|
-
|
|
46
|
+
return {
|
|
47
|
+
...defaultOptions,
|
|
48
|
+
...newOptions
|
|
49
|
+
};
|
|
50
|
+
}
|
|
38
51
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
52
|
+
browsers.forEach(browser => {
|
|
53
|
+
it(`should all fail, bad remote sitemap - ${browser}`, function (done) {
|
|
54
|
+
const options = createOptions({
|
|
55
|
+
browser
|
|
56
|
+
});
|
|
43
57
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
58
|
+
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
59
|
+
|
|
60
|
+
ss.run(optHelp.decorate(options), twice)
|
|
61
|
+
.then(unexpectedSuccess.bind(null, done))
|
|
62
|
+
.catch(twice);
|
|
63
|
+
});
|
|
48
64
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
65
|
+
it("TODO: write more failure tests", function (done) {
|
|
66
|
+
assert.ok(true, "TODO");
|
|
67
|
+
done();
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it(`should succeed simple case - ${browser}`, function (done) {
|
|
71
|
+
const options = createOptions({
|
|
72
|
+
source: `http://localhost:${port}/public/page-sitemap.xml`,
|
|
73
|
+
browser
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const twice = _.after(2, cleanupSuccess.bind(null, done));
|
|
77
|
+
const success = (err, completed) => {
|
|
78
|
+
assert.equal(completed.length, urls);
|
|
79
|
+
testSuccess(twice, completed);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
ss.run(optHelp.decorate(options), success)
|
|
83
|
+
.then(success.bind(null, undefined))
|
|
84
|
+
.catch(e => {
|
|
85
|
+
checkActualFiles(e.notCompleted)
|
|
86
|
+
.then(() => {
|
|
87
|
+
cleanup(done, e);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("TODO: write more success tests", function (done) {
|
|
93
|
+
assert.ok(true, "TODO");
|
|
94
|
+
done();
|
|
95
|
+
});
|
|
96
|
+
});
|
|
53
97
|
};
|
|
54
98
|
}
|
|
55
99
|
|
|
@@ -4,194 +4,199 @@
|
|
|
4
4
|
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
5
|
*/
|
|
6
6
|
/* global beforeEach, describe, it */
|
|
7
|
-
// var assert = require("assert");
|
|
8
|
-
var path = require("path");
|
|
9
|
-
var fs = require("fs");
|
|
10
|
-
var _ = require("lodash");
|
|
11
|
-
var rimraf = require("rimraf").sync;
|
|
12
|
-
var utils = require("./utils");
|
|
13
|
-
var optHelp = require("../../helpers/options");
|
|
14
|
-
var ss = require("../../../lib/html-snapshots");
|
|
15
|
-
var inputFile = require("./robots").inputFile;
|
|
16
7
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
8
|
+
const path = require("path");
|
|
9
|
+
const fs = require("fs");
|
|
10
|
+
const _ = require("lodash");
|
|
11
|
+
const rimraf = require("rimraf").sync;
|
|
12
|
+
const utils = require("./utils");
|
|
13
|
+
const optHelp = require("../../helpers/options");
|
|
14
|
+
const ss = require("../../../lib/html-snapshots");
|
|
15
|
+
|
|
16
|
+
const {
|
|
17
|
+
timeout,
|
|
18
|
+
outputDir,
|
|
19
|
+
cleanup,
|
|
20
|
+
bogusFile,
|
|
21
|
+
cleanupError,
|
|
22
|
+
unexpectedSuccess,
|
|
23
|
+
checkActualFiles
|
|
24
|
+
} = utils;
|
|
25
25
|
|
|
26
26
|
function snapshotScriptTests (options) {
|
|
27
|
-
|
|
27
|
+
const {
|
|
28
|
+
localRobotsFile: inputFile,
|
|
29
|
+
port,
|
|
30
|
+
browsers
|
|
31
|
+
} = options;
|
|
28
32
|
|
|
29
33
|
return function () {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
34
|
+
const removeScriptsConfig = {
|
|
35
|
+
name: "removeScripts",
|
|
36
|
+
option: {
|
|
37
|
+
script: "removeScripts"
|
|
38
|
+
},
|
|
39
|
+
browser: "phantomjs",
|
|
40
|
+
prove: (completed, done) => {
|
|
41
|
+
// console.log("@@@ removeScripts prove @@@");
|
|
42
|
+
let content, err;
|
|
43
|
+
for (var i = 0; i < completed.length; i++) {
|
|
44
|
+
content = fs.readFileSync(completed[i], { encoding: "utf8" });
|
|
45
|
+
if (/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi.test(content)) {
|
|
46
|
+
err = new Error("removeScripts failed. Script tag found in "+completed[i]);
|
|
47
|
+
break;
|
|
45
48
|
}
|
|
46
|
-
done(err);
|
|
47
49
|
}
|
|
50
|
+
done(err);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const customFilterConfig = {
|
|
54
|
+
name: "customFilter",
|
|
55
|
+
option: {
|
|
56
|
+
script: "customFilter",
|
|
57
|
+
module: path.join(__dirname, "myFilter.js")
|
|
48
58
|
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
content = fs.readFileSync(completed[i], { encoding: "utf8" });
|
|
61
|
-
// this is dependent on myFilter.js adding someattrZZQy anywhere
|
|
62
|
-
if (content.indexOf("someattrZZQy") < 0) {
|
|
63
|
-
err = new Error("customFilter snapshotScript failed. Special sequence not found in "+completed[i]);
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
59
|
+
browser: "phantomjs",
|
|
60
|
+
prove: (completed, done) => {
|
|
61
|
+
// console.log("@@@ customFilter prove @@@");
|
|
62
|
+
let content, err;
|
|
63
|
+
for (let i = 0; i < completed.length; i++) {
|
|
64
|
+
// console.log("@@@ readFile "+completed[i]);
|
|
65
|
+
content = fs.readFileSync(completed[i], { encoding: "utf8" });
|
|
66
|
+
// this is dependent on myFilter.js adding someattrZZQy anywhere
|
|
67
|
+
if (content.indexOf("someattrZZQy") < 0) {
|
|
68
|
+
err = new Error("customFilter snapshotScript failed. Special sequence not found in "+completed[i]);
|
|
69
|
+
break;
|
|
66
70
|
}
|
|
67
|
-
done(err);
|
|
68
71
|
}
|
|
72
|
+
done(err);
|
|
69
73
|
}
|
|
70
|
-
|
|
71
|
-
|
|
74
|
+
};
|
|
75
|
+
const snapshotScriptTests = [];
|
|
76
|
+
browsers.forEach(browser => {
|
|
77
|
+
snapshotScriptTests.push({
|
|
78
|
+
...removeScriptsConfig,
|
|
79
|
+
...{
|
|
80
|
+
name: `${removeScriptsConfig.name}-${browser}`,
|
|
81
|
+
browser
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
snapshotScriptTests.push({
|
|
85
|
+
...customFilterConfig,
|
|
86
|
+
...{
|
|
87
|
+
name: `${customFilterConfig.name}-${browser}`,
|
|
88
|
+
browser
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
72
93
|
describe("should succeed for scripts", function () {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
snapshotScriptTests[testNumber + 1].name
|
|
76
|
-
//, testNumber + 2, etc
|
|
77
|
-
];
|
|
94
|
+
let testNumber = 0, snapshotScriptTest;
|
|
95
|
+
const scriptNames = snapshotScriptTests.map(test => test.name);
|
|
78
96
|
|
|
79
97
|
beforeEach(function () {
|
|
80
98
|
snapshotScriptTest = snapshotScriptTests[testNumber++];
|
|
81
99
|
});
|
|
82
100
|
|
|
83
101
|
function snapshotScriptTestDefinition (done) {
|
|
84
|
-
|
|
102
|
+
const options = {
|
|
85
103
|
source: inputFile,
|
|
86
104
|
hostname: "localhost",
|
|
87
|
-
port: port,
|
|
88
105
|
selector: "#dynamic-content",
|
|
89
|
-
outputDir: outputDir,
|
|
90
106
|
outputDirClean: true,
|
|
91
107
|
timeout: timeout,
|
|
92
|
-
snapshotScript: snapshotScriptTest.option
|
|
108
|
+
snapshotScript: snapshotScriptTest.option,
|
|
109
|
+
browser: snapshotScriptTest.browser,
|
|
110
|
+
outputDir,
|
|
111
|
+
port
|
|
93
112
|
};
|
|
94
113
|
|
|
95
114
|
rimraf(outputDir);
|
|
96
115
|
|
|
97
116
|
ss.run(optHelp.decorate(options))
|
|
98
|
-
.then(
|
|
99
|
-
snapshotScriptTest.prove(completed,
|
|
117
|
+
.then(completed => {
|
|
118
|
+
snapshotScriptTest.prove(completed, e => {
|
|
100
119
|
cleanup(done, e);
|
|
101
120
|
});
|
|
102
121
|
})
|
|
103
|
-
.catch(
|
|
122
|
+
.catch(err => {
|
|
104
123
|
checkActualFiles(err.notCompleted)
|
|
105
|
-
.then(
|
|
124
|
+
.then(() => {
|
|
106
125
|
cleanup(done, err);
|
|
107
126
|
});
|
|
108
127
|
});
|
|
109
128
|
}
|
|
110
129
|
|
|
111
|
-
scriptNames.forEach(
|
|
112
|
-
it(
|
|
130
|
+
scriptNames.forEach((scriptName, i) => {
|
|
131
|
+
it(`snapshot script ${scriptName}, ${snapshotScriptTests[i].browser}`, function (done) {
|
|
113
132
|
setTimeout(snapshotScriptTestDefinition, 3000, done);
|
|
114
133
|
});
|
|
115
134
|
});
|
|
116
135
|
});
|
|
117
136
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
it("should fail if a bogus script object is supplied", function(done) {
|
|
137
|
-
var options = {
|
|
138
|
-
source: inputFile,
|
|
139
|
-
hostname: "localhost",
|
|
140
|
-
port: port,
|
|
141
|
-
selector: "#dynamic-content",
|
|
142
|
-
outputDir: outputDir,
|
|
143
|
-
outputDirClean: true,
|
|
144
|
-
snapshotScript: {
|
|
145
|
-
script: bogusFile
|
|
146
|
-
},
|
|
147
|
-
timeout: 2000
|
|
148
|
-
};
|
|
149
|
-
var twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
150
|
-
|
|
151
|
-
ss.run(optHelp.decorate(options), twice)
|
|
152
|
-
.then(unexpectedSuccess.bind(null, done))
|
|
153
|
-
.catch(twice);
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
it("should fail if a customFilter is defined but no module", function(done) {
|
|
157
|
-
var options = {
|
|
158
|
-
source: inputFile,
|
|
159
|
-
hostname: "localhost",
|
|
160
|
-
port: port,
|
|
161
|
-
selector: "#dynamic-content",
|
|
162
|
-
outputDir: outputDir,
|
|
163
|
-
outputDirClean: true,
|
|
164
|
-
snapshotScript: {
|
|
165
|
-
script: "customFilter"
|
|
166
|
-
},
|
|
167
|
-
timeout: 2000
|
|
168
|
-
};
|
|
169
|
-
var twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
170
|
-
|
|
171
|
-
ss.run(optHelp.decorate(options), twice)
|
|
172
|
-
.then(unexpectedSuccess.bind(null, done))
|
|
173
|
-
.catch(twice);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it("should fail if a customFilter is defined and bogus module", function(done) {
|
|
177
|
-
var options = {
|
|
178
|
-
source: inputFile,
|
|
179
|
-
hostname: "localhost",
|
|
180
|
-
port: port,
|
|
181
|
-
selector: "#dynamic-content",
|
|
182
|
-
outputDir: outputDir,
|
|
183
|
-
outputDirClean: true,
|
|
184
|
-
snapshotScript: {
|
|
185
|
-
script: "customFilter",
|
|
186
|
-
module: bogusFile
|
|
187
|
-
},
|
|
188
|
-
timeout: 2000
|
|
189
|
-
};
|
|
190
|
-
var twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
137
|
+
describe("should fail for scripts", function () {
|
|
138
|
+
function createOptions (newOptions) {
|
|
139
|
+
const defaultOptions = {
|
|
140
|
+
source: inputFile,
|
|
141
|
+
hostname: "localhost",
|
|
142
|
+
selector: "#dynamic-content",
|
|
143
|
+
outputDirClean: true,
|
|
144
|
+
snapshotScript: bogusFile,
|
|
145
|
+
timeout: 2000,
|
|
146
|
+
outputDir,
|
|
147
|
+
port
|
|
148
|
+
};
|
|
149
|
+
return {
|
|
150
|
+
...defaultOptions,
|
|
151
|
+
...newOptions
|
|
152
|
+
};
|
|
153
|
+
}
|
|
191
154
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
155
|
+
const testOptions = [{
|
|
156
|
+
name: "should fail if a bogus script string is supplied",
|
|
157
|
+
options: {
|
|
158
|
+
snapshotScript: bogusFile
|
|
159
|
+
}
|
|
160
|
+
}, {
|
|
161
|
+
name: "should fail if a bogus script object is supplied",
|
|
162
|
+
options: {
|
|
163
|
+
snapshotScript: {
|
|
164
|
+
script: bogusFile
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}, {
|
|
168
|
+
name: "should fail if a customFilter is defined but no module",
|
|
169
|
+
options: {
|
|
170
|
+
snapshotScript: {
|
|
171
|
+
script: "customFilter"
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}, {
|
|
175
|
+
name: "should fail if a customFilter is defined and bogus module",
|
|
176
|
+
options: {
|
|
177
|
+
browser: "phantomjs",
|
|
178
|
+
snapshotScript: {
|
|
179
|
+
script: "customFilter",
|
|
180
|
+
module: bogusFile
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}];
|
|
184
|
+
const driverOptions = browsers.map(browser => {
|
|
185
|
+
return testOptions.map(test => {
|
|
186
|
+
test.options.browser = browser;
|
|
187
|
+
return JSON.parse(JSON.stringify(test));
|
|
188
|
+
});
|
|
189
|
+
}).flat();
|
|
190
|
+
|
|
191
|
+
driverOptions.forEach(driver => {
|
|
192
|
+
it(driver.name, function (done) {
|
|
193
|
+
const options = createOptions(driver.options);
|
|
194
|
+
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
195
|
+
ss.run(optHelp.decorate(options), twice)
|
|
196
|
+
.then(unexpectedSuccess.bind(null, done))
|
|
197
|
+
.catch(twice);
|
|
198
|
+
});
|
|
199
|
+
});
|
|
195
200
|
});
|
|
196
201
|
};
|
|
197
202
|
}
|
|
@@ -4,19 +4,22 @@
|
|
|
4
4
|
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
5
|
*/
|
|
6
6
|
/* global describe, before, after */
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const enableDestroy = require("server-destroy");
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
const { timeout } = require("./utils");
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
const basics = require("./basics");
|
|
13
|
+
const robots = require("./robots");
|
|
14
|
+
const sitemap = require("./sitemap");
|
|
15
|
+
const sitemapIndex = require("./sitemap-index");
|
|
16
|
+
const processLimit = require("./process-limit");
|
|
17
|
+
const useJQuery = require("./use-jquery");
|
|
18
|
+
const snapshotScripts = require("./snapshot-scripts");
|
|
19
|
+
const phantomJSOptions = require("./phantomjs-options");
|
|
20
|
+
const puppeteer = require("./puppeteer");
|
|
21
|
+
|
|
22
|
+
const localRobotsFile = path.join(__dirname, "./test_robots.txt");
|
|
20
23
|
|
|
21
24
|
/**
|
|
22
25
|
* Create a test context with a new server on a port.
|
|
@@ -28,10 +31,10 @@ var phantomJSOptions = require("./phantomjs-options");
|
|
|
28
31
|
* @returns {Function} A test context with server management.
|
|
29
32
|
*/
|
|
30
33
|
function serverContext (testSuiteFactory, port) {
|
|
31
|
-
|
|
34
|
+
const server = require("../../server");
|
|
32
35
|
|
|
33
36
|
return function () {
|
|
34
|
-
|
|
37
|
+
let httpServer;
|
|
35
38
|
|
|
36
39
|
before(function (done) {
|
|
37
40
|
server.start(path.join(__dirname, "./server"), port,
|
|
@@ -53,7 +56,9 @@ function serverContext (testSuiteFactory, port) {
|
|
|
53
56
|
});
|
|
54
57
|
|
|
55
58
|
describe("tests", testSuiteFactory({
|
|
56
|
-
port
|
|
59
|
+
port,
|
|
60
|
+
localRobotsFile,
|
|
61
|
+
browsers: ["phantomjs", "puppeteer"]
|
|
57
62
|
}));
|
|
58
63
|
};
|
|
59
64
|
}
|
|
@@ -68,6 +73,10 @@ describe("html-snapshots", function () {
|
|
|
68
73
|
"phantomjsOptions option", serverContext(phantomJSOptions.testSuite, 8035)
|
|
69
74
|
);
|
|
70
75
|
|
|
76
|
+
describe(
|
|
77
|
+
"puppeteer specific tests", serverContext(puppeteer.testSuite, 8042)
|
|
78
|
+
);
|
|
79
|
+
|
|
71
80
|
describe(
|
|
72
81
|
"additional snapshot scripts", serverContext(snapshotScripts.testSuite, 8036)
|
|
73
82
|
);
|