html-snapshots 0.19.0 → 1.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/.github/workflows/verify.yml +2 -2
- package/HISTORY.md +42 -0
- package/README.md +92 -244
- package/examples/README.md +149 -0
- package/examples/custom/package-lock.json +1090 -9
- package/examples/custom/package.json +1 -1
- package/examples/debug-phantomjs/package-lock.json +1977 -292
- package/examples/debug-phantomjs/package.json +1 -1
- package/examples/debug-phantomjs/snapshot.js +1 -0
- 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 +734 -18
- package/examples/html5rocks/package.json +1 -1
- package/examples/html5rocks/snapshot.js +0 -6
- package/examples/process-limit/package-lock.json +734 -18
- package/examples/process-limit/package.json +1 -1
- package/examples/simple-promise/package-lock.json +734 -18
- package/examples/simple-promise/package.json +1 -1
- package/examples/sitemap-index/package-lock.json +734 -18
- package/examples/sitemap-index/package.json +1 -1
- package/examples/sitemap-index/snapshot.js +0 -1
- package/examples/verbose/package-lock.json +734 -19
- package/examples/verbose/package.json +1 -1
- package/examples/verbose/snapshot.js +1 -0
- package/lib/html-snapshots.js +87 -4
- package/lib/input-generators/_base.js +7 -1
- package/lib/puppeteer/index.js +98 -0
- package/lib/puppeteer/removeScripts.js +8 -0
- package/package.json +6 -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 +100 -92
- package/test/mocha/html-snapshots/puppeteer.js +47 -0
- package/test/mocha/html-snapshots/robots.js +137 -120
- package/test/mocha/html-snapshots/server/public/page-sitemap.xml +16 -0
- package/test/mocha/html-snapshots/sitemap-index.js +89 -80
- package/test/mocha/html-snapshots/sitemap.js +75 -31
- package/test/mocha/html-snapshots/snapshot-scripts.js +124 -120
- package/test/mocha/html-snapshots/test.js +11 -2
- package/test/mocha/html-snapshots/use-jquery.js +65 -64
- package/test/mocha/html-snapshots/utils.js +29 -29
- package/examples/utils/index.js +0 -25
|
@@ -29,7 +29,11 @@ const urls = 3; // must match url # in robots files test fixtures.
|
|
|
29
29
|
* The robots test suite.
|
|
30
30
|
*/
|
|
31
31
|
function robotsTests (options) {
|
|
32
|
-
const {
|
|
32
|
+
const {
|
|
33
|
+
port,
|
|
34
|
+
localRobotsFile,
|
|
35
|
+
browsers
|
|
36
|
+
} = options;
|
|
33
37
|
|
|
34
38
|
// Robots.txt fixtures
|
|
35
39
|
const inputFiles = [
|
|
@@ -39,133 +43,146 @@ function robotsTests (options) {
|
|
|
39
43
|
];
|
|
40
44
|
|
|
41
45
|
return function () {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
cleanup(done, e);
|
|
63
|
-
});
|
|
46
|
+
function createOptions (newOptions) {
|
|
47
|
+
const options = {
|
|
48
|
+
hostname: "localhost",
|
|
49
|
+
selector: "#dynamic-content",
|
|
50
|
+
outputDirClean: true,
|
|
51
|
+
outputDir,
|
|
52
|
+
timeout,
|
|
53
|
+
port
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
...options,
|
|
57
|
+
...newOptions
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
browsers.forEach(browser => {
|
|
61
|
+
inputFiles.forEach(inputFile => {
|
|
62
|
+
it(`should succeed, no output dir pre-exists, ${browser}, ${inputFile}`, function (done) {
|
|
63
|
+
const options = createOptions({
|
|
64
|
+
source: inputFile,
|
|
65
|
+
browser
|
|
64
66
|
});
|
|
65
|
-
});
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
});
|
|
68
|
+
const twice = _.after(2, cleanupSuccess.bind(null, done));
|
|
69
|
+
|
|
70
|
+
rimraf(outputDir);
|
|
71
|
+
|
|
72
|
+
ss.run(optHelp.decorate(options), twice)
|
|
73
|
+
.then(testSuccess.bind(null, twice))
|
|
74
|
+
.catch(e => {
|
|
75
|
+
checkActualFiles(e.notCompleted)
|
|
76
|
+
.then(() => {
|
|
77
|
+
cleanup(done, e);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it(`should succeed, output dir does pre-exist, ${browser}, ${inputFile}`, function (done) {
|
|
83
|
+
const options = createOptions({
|
|
84
|
+
source: inputFile,
|
|
85
|
+
browser
|
|
86
86
|
});
|
|
87
|
-
});
|
|
88
87
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
88
|
+
const twice = _.after(2, cleanupSuccess.bind(null, done));
|
|
89
|
+
|
|
90
|
+
ss.run(optHelp.decorate(options), twice)
|
|
91
|
+
.then(testSuccess.bind(null, twice))
|
|
92
|
+
.catch(e => {
|
|
93
|
+
checkActualFiles(e.notCompleted)
|
|
94
|
+
.then(() => {
|
|
95
|
+
cleanup(done, e);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it(`should fail with bad phantomjs process to spawn, succeed otherwise, ${browser}, ${inputFile}`,
|
|
101
|
+
function (done) {
|
|
102
|
+
const options = createOptions({
|
|
103
|
+
source: inputFile,
|
|
104
|
+
browser,
|
|
105
|
+
phantomjs: bogusFile,
|
|
106
|
+
timeout: 1000
|
|
107
|
+
});
|
|
107
108
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
109
|
+
if (browser === "phantomjs") {
|
|
110
|
+
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
111
|
+
|
|
112
|
+
ss.run(options, twice)
|
|
113
|
+
.then(unexpectedSuccess.bind(null, done))
|
|
114
|
+
.catch(twice);
|
|
115
|
+
} else {
|
|
116
|
+
options.timeout = utils.timeout;
|
|
117
|
+
const twice = _.after(2, cleanupSuccess.bind(null, done));
|
|
118
|
+
|
|
119
|
+
ss.run(optHelp.decorate(options), twice)
|
|
120
|
+
.then(testSuccess.bind(null, twice))
|
|
121
|
+
.catch(e => {
|
|
122
|
+
checkActualFiles(e.notCompleted)
|
|
123
|
+
.then(() => {
|
|
124
|
+
cleanup(done, e);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it(`should fail, bad remote robots, ${browser}, ${inputFile}`, function (done) {
|
|
131
|
+
const options = createOptions({
|
|
132
|
+
input: "robots",
|
|
133
|
+
source: `http://localhost:${port}/index.html`,
|
|
134
|
+
timeout: 5000,
|
|
135
|
+
browser
|
|
136
|
+
});
|
|
124
137
|
|
|
125
|
-
|
|
126
|
-
const options = {
|
|
127
|
-
source: inputFile,
|
|
128
|
-
hostname: "localhost",
|
|
129
|
-
selector: "#dynamic-content-notexist",
|
|
130
|
-
outputDirClean: true,
|
|
131
|
-
timeout: 6000,
|
|
132
|
-
outputDir,
|
|
133
|
-
port
|
|
134
|
-
};
|
|
135
|
-
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
136
|
-
|
|
137
|
-
ss.run(optHelp.decorate(options), twice)
|
|
138
|
-
.then(unexpectedSuccess.bind(null, done))
|
|
139
|
-
.catch(twice);
|
|
140
|
-
});
|
|
138
|
+
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
141
139
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
140
|
+
ss.run(optHelp.decorate(options), twice)
|
|
141
|
+
.then(unexpectedSuccess.bind(null, done))
|
|
142
|
+
.catch(twice);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it(`should fail, non-existent selector, ${browser}, ${inputFile}`, function (done) {
|
|
146
|
+
const options = createOptions({
|
|
147
|
+
source: inputFile,
|
|
148
|
+
selector: "#dynamic-content-notexist",
|
|
149
|
+
timeout: 5000,
|
|
150
|
+
browser
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
154
|
+
|
|
155
|
+
ss.run(optHelp.decorate(options), twice)
|
|
156
|
+
.then(unexpectedSuccess.bind(null, done))
|
|
157
|
+
.catch(twice);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it(`should fail one snapshot, one non-existent selector, ${browser}, ${inputFile}`, function (done) {
|
|
161
|
+
let exceptionUrl = "/";
|
|
162
|
+
if (common.isUrl(inputFile)) {
|
|
163
|
+
// assume the origin of the inputFile is the same as the contents of the remote urls within it.
|
|
164
|
+
const url = new URL(inputFile);
|
|
165
|
+
const isSitemap = url.pathname.includes('sitemap');
|
|
166
|
+
if (isSitemap) {
|
|
167
|
+
exceptionUrl = `${url.origin}${exceptionUrl}`;
|
|
168
|
+
}
|
|
150
169
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
.then(unexpectedSuccess.bind(null, done))
|
|
168
|
-
.catch(twice);
|
|
170
|
+
const options = createOptions({
|
|
171
|
+
source: inputFile,
|
|
172
|
+
selector: {
|
|
173
|
+
"__default": "#dynamic-content",
|
|
174
|
+
[exceptionUrl]: "#dynamic-content-notexist"
|
|
175
|
+
},
|
|
176
|
+
timeout: 5000,
|
|
177
|
+
browser
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
const twice = _.after(2, cleanupError.bind(null, done, urls - 1));
|
|
181
|
+
|
|
182
|
+
ss.run(optHelp.decorate(options), twice)
|
|
183
|
+
.then(unexpectedSuccess.bind(null, done))
|
|
184
|
+
.catch(twice);
|
|
185
|
+
});
|
|
169
186
|
});
|
|
170
187
|
});
|
|
171
188
|
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet type="text/xsl" href="//core.codekraft.it/public/wordpress/main-sitemap.xsl"?>
|
|
2
|
+
<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
|
|
3
|
+
<url>
|
|
4
|
+
<loc>http://localhost:8039/</loc>
|
|
5
|
+
</url>
|
|
6
|
+
<url>
|
|
7
|
+
<loc>http://localhost:8039/contact</loc>
|
|
8
|
+
<lastmod>2017-01-06T21:06:08+01:00</lastmod>
|
|
9
|
+
</url>
|
|
10
|
+
<url>
|
|
11
|
+
<loc>http://localhost:8039/services/carpets</loc>
|
|
12
|
+
<lastmod>2017-01-09T22:38:33+01:00</lastmod>
|
|
13
|
+
</url>
|
|
14
|
+
</urlset>
|
|
15
|
+
<!-- XML Sitemap generated by Yoast SEO -->
|
|
16
|
+
<!-- 24.04MB | Served from transient cache -->
|
|
@@ -31,95 +31,104 @@ function getClass (obj) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
function sitemapIndexTests (options) {
|
|
34
|
-
const
|
|
34
|
+
const {
|
|
35
|
+
port,
|
|
36
|
+
browsers
|
|
37
|
+
} = options;
|
|
35
38
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
function createOptions (newOptions) {
|
|
40
|
+
const options = {
|
|
41
|
+
source: `http://localhost:${port}/${sitemapIndexFile}`,
|
|
42
|
+
input: "sitemap-index",
|
|
43
|
+
selector: "#dynamic-content",
|
|
44
|
+
outputDirClean: true,
|
|
45
|
+
outputDir,
|
|
46
|
+
timeout
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
...options,
|
|
51
|
+
...newOptions
|
|
52
|
+
};
|
|
53
|
+
}
|
|
46
54
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
assert.equal(completed.length, urls);
|
|
53
|
-
} catch (e) {
|
|
54
|
-
assertionError = e;
|
|
55
|
-
}
|
|
56
|
-
cleanup(done, assertionError);
|
|
57
|
-
})
|
|
58
|
-
.catch(err => {
|
|
59
|
-
checkActualFiles(err.notCompleted)
|
|
60
|
-
.then(() => {
|
|
61
|
-
cleanup(done, err || unexpectedError);
|
|
62
|
-
});
|
|
55
|
+
return function () {
|
|
56
|
+
browsers.forEach(browser => {
|
|
57
|
+
it(`should succeed for typical sitemap-index usage - ${browser}`, function (done) {
|
|
58
|
+
const options = createOptions({
|
|
59
|
+
browser
|
|
63
60
|
});
|
|
64
|
-
});
|
|
65
61
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
62
|
+
ss.run(optHelp.decorate(options))
|
|
63
|
+
.then(function (completed) {
|
|
64
|
+
let assertionError;
|
|
65
|
+
try {
|
|
66
|
+
assert.equal(getClass(completed), "Array");
|
|
67
|
+
assert.equal(completed.length, urls);
|
|
68
|
+
} catch (e) {
|
|
69
|
+
assertionError = e;
|
|
70
|
+
}
|
|
71
|
+
cleanup(done, assertionError);
|
|
72
|
+
})
|
|
73
|
+
.catch(err => {
|
|
74
|
+
checkActualFiles(err.notCompleted)
|
|
75
|
+
.then(() => {
|
|
76
|
+
cleanup(done, err || unexpectedError);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
});
|
|
77
80
|
|
|
78
|
-
|
|
79
|
-
.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
// fails fast:
|
|
85
|
-
assert.equal(err.notCompleted.length, 0);
|
|
86
|
-
} catch (e) {
|
|
87
|
-
assertionError = e;
|
|
88
|
-
}
|
|
89
|
-
cleanup(done, assertionError);
|
|
81
|
+
it(`should fail fast for bad sitemap url - ${browser}`, function (done) {
|
|
82
|
+
const sitemapIndexFile3 = path.basename(sitemapIndexFile, ".xml") + "-3" +
|
|
83
|
+
path.extname(sitemapIndexFile);
|
|
84
|
+
const options = createOptions({
|
|
85
|
+
source: `http://localhost:${port}/${sitemapIndexFile3}`,
|
|
86
|
+
browser
|
|
90
87
|
});
|
|
91
|
-
});
|
|
92
88
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
};
|
|
89
|
+
ss.run(optHelp.decorate(options))
|
|
90
|
+
.then(unexpectedSuccess)
|
|
91
|
+
.catch(err => {
|
|
92
|
+
let assertionError;
|
|
93
|
+
try {
|
|
94
|
+
assert.equal(getClass(err.notCompleted), "Array");
|
|
95
|
+
// fails fast:
|
|
96
|
+
assert.equal(err.notCompleted.length, 0);
|
|
97
|
+
} catch (e) {
|
|
98
|
+
assertionError = e;
|
|
99
|
+
}
|
|
100
|
+
cleanup(done, assertionError);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
108
103
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
}
|
|
121
|
-
cleanup(done, assertionError);
|
|
104
|
+
it(`should eventually fail for bad page url - ${browser}`, function (done) {
|
|
105
|
+
const eventually = 1000;
|
|
106
|
+
const sitemapIndexFile2 = path.basename(sitemapIndexFile, ".xml") + "-2" +
|
|
107
|
+
path.extname(sitemapIndexFile);
|
|
108
|
+
const options = createOptions({
|
|
109
|
+
source: `http://localhost:${port}/${sitemapIndexFile2}`,
|
|
110
|
+
timeout: {
|
|
111
|
+
"http://localhost:8040/services/bad": eventually,
|
|
112
|
+
__default: timeout
|
|
113
|
+
},
|
|
114
|
+
browser
|
|
122
115
|
});
|
|
116
|
+
|
|
117
|
+
ss.run(optHelp.decorate(options))
|
|
118
|
+
.then(unexpectedSuccess)
|
|
119
|
+
.catch(err => {
|
|
120
|
+
let assertionError;
|
|
121
|
+
try {
|
|
122
|
+
assert.equal(getClass(err.completed), "Array");
|
|
123
|
+
assert.equal(err.completed.length, urls - 1);
|
|
124
|
+
assert.equal(getClass(err.notCompleted), "Array");
|
|
125
|
+
assert.equal(err.notCompleted.length, 1);
|
|
126
|
+
} catch (e) {
|
|
127
|
+
assertionError = e;
|
|
128
|
+
}
|
|
129
|
+
cleanup(done, assertionError);
|
|
130
|
+
});
|
|
131
|
+
});
|
|
123
132
|
});
|
|
124
133
|
};
|
|
125
134
|
}
|
|
@@ -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
|
|