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.
Files changed (84) hide show
  1. package/.eslintrc.json +4 -5
  2. package/.github/workflows/verify.yml +2 -2
  3. package/HISTORY.md +42 -0
  4. package/README.md +109 -256
  5. package/examples/README.md +149 -0
  6. package/examples/custom/myFilter.js +2 -2
  7. package/examples/custom/package-lock.json +2021 -5
  8. package/examples/custom/package.json +1 -1
  9. package/examples/custom/snapshot.js +8 -10
  10. package/examples/debug-phantomjs/package-lock.json +6 -6
  11. package/examples/debug-phantomjs/package.json +1 -1
  12. package/examples/debug-phantomjs/snapshot.js +13 -14
  13. package/examples/debug-puppeteer/README.md +18 -0
  14. package/examples/debug-puppeteer/package-lock.json +2804 -0
  15. package/examples/debug-puppeteer/package.json +12 -0
  16. package/examples/debug-puppeteer/snapshot.js +30 -0
  17. package/examples/html5rocks/package-lock.json +1306 -5
  18. package/examples/html5rocks/package.json +1 -1
  19. package/examples/html5rocks/snapshot.js +14 -23
  20. package/examples/process-limit/package-lock.json +1306 -5
  21. package/examples/process-limit/package.json +1 -1
  22. package/examples/process-limit/snapshot.js +8 -10
  23. package/examples/simple-promise/package-lock.json +1306 -5
  24. package/examples/simple-promise/package.json +1 -1
  25. package/examples/simple-promise/snapshot.js +6 -8
  26. package/examples/sitemap-index/package-lock.json +1306 -5
  27. package/examples/sitemap-index/package.json +1 -1
  28. package/examples/sitemap-index/snapshot.js +6 -6
  29. package/examples/utils/index.js +2 -4
  30. package/examples/verbose/package-lock.json +1306 -5
  31. package/examples/verbose/package.json +1 -1
  32. package/examples/verbose/snapshot.js +12 -14
  33. package/lib/async/index.js +0 -1
  34. package/lib/common/index.js +1 -1
  35. package/lib/common/sitemap/index.js +16 -0
  36. package/lib/common/sitemap/sitemap-collection.js +94 -0
  37. package/lib/common/sitemap/sitemap-index.js +68 -0
  38. package/lib/common/{sitemap.js → sitemap/sitemap.js} +68 -57
  39. package/lib/html-snapshots.js +87 -5
  40. package/lib/input-generators/_base.js +7 -1
  41. package/lib/input-generators/array.js +0 -1
  42. package/lib/input-generators/robots.js +98 -58
  43. package/lib/input-generators/sitemap-index.js +3 -124
  44. package/lib/input-generators/sitemap.js +3 -7
  45. package/lib/input-generators/textfile.js +2 -6
  46. package/lib/puppeteer/index.js +98 -0
  47. package/lib/puppeteer/removeScripts.js +8 -0
  48. package/package.json +9 -4
  49. package/test/helpers/options.js +4 -2
  50. package/test/mocha/browsers/puppeteer.js +106 -0
  51. package/test/mocha/browsers/server/index.html +9 -0
  52. package/test/mocha/browsers/test.js +11 -0
  53. package/test/mocha/html-snapshots/basics.js +60 -47
  54. package/test/mocha/html-snapshots/phantomjs-options.js +54 -60
  55. package/test/mocha/html-snapshots/process-limit.js +126 -120
  56. package/test/mocha/html-snapshots/puppeteer.js +47 -0
  57. package/test/mocha/html-snapshots/robots.js +156 -121
  58. package/test/mocha/html-snapshots/server/public/page-sitemap.xml +16 -0
  59. package/test/mocha/html-snapshots/server/test_robots.txt +13 -0
  60. package/test/mocha/html-snapshots/server/test_robots_sitemap.txt +15 -0
  61. package/test/mocha/html-snapshots/server/test_robots_sitemap.xml +22 -0
  62. package/test/mocha/html-snapshots/sitemap-index.js +100 -90
  63. package/test/mocha/html-snapshots/sitemap.js +75 -31
  64. package/test/mocha/html-snapshots/snapshot-scripts.js +150 -145
  65. package/test/mocha/html-snapshots/test.js +23 -14
  66. package/test/mocha/html-snapshots/test_robots.txt +0 -2
  67. package/test/mocha/html-snapshots/use-jquery.js +65 -64
  68. package/test/mocha/html-snapshots/utils.js +29 -30
  69. package/test/mocha/input-generators/server/test_robots.txt +0 -2
  70. package/test/mocha/input-generators/server/test_robots_bad.txt +0 -2
  71. package/test/mocha/input-generators/server/test_robots_sitemap.txt +17 -0
  72. package/test/mocha/input-generators/server/test_robots_sitemap_bad.txt +17 -0
  73. package/test/mocha/input-generators/server/test_robots_sitemap_multi.txt +18 -0
  74. package/test/mocha/input-generators/server/test_sitemap_index_empty.xml +3 -0
  75. package/test/mocha/input-generators/server/test_sitemap_index_malformed.xml +2 -0
  76. package/test/mocha/input-generators/sitemap-index.js +65 -9
  77. package/test/mocha/input-generators/test.js +276 -280
  78. package/test/mocha/input-generators/test_robots.txt +0 -2
  79. package/test/mocha/input-generators/test_robots_bad.txt +0 -2
  80. package/test/mocha/input-generators/test_robots_sitemap.txt +17 -0
  81. package/test/mocha/input-generators/test_robots_sitemap_bad.txt +17 -0
  82. package/test/mocha/input-generators/test_robots_sitemap_multi.txt +18 -0
  83. package/lib/common/node.js +0 -26
  84. package/test/mocha/common/node.js +0 -100
@@ -4,156 +4,191 @@
4
4
  * Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
5
5
  */
6
6
  /* global it */
7
- var path = require("path");
8
- var rimraf = require("rimraf").sync;
9
- var _ = require("lodash");
10
- var optHelp = require("../../helpers/options");
11
- var ss = require("../../../lib/html-snapshots");
12
- var utils = require("./utils");
13
-
14
- // missing destructuring, will write postcard...
15
- var timeout = utils.timeout;
16
- var outputDir = utils.outputDir;
17
- var cleanup = utils.cleanup;
18
- var cleanupSuccess = utils.cleanupSuccess;
19
- var cleanupError = utils.cleanupError;
20
- var testSuccess = utils.testSuccess;
21
- var bogusFile = utils.bogusFile;
22
- var unexpectedSuccess = utils.unexpectedSuccess;
23
- var checkActualFiles = utils.checkActualFiles;
24
-
25
- // Robots constants
26
- var inputFile = path.join(__dirname, "./test_robots.txt");
27
- var urls = 3; // must match test_robots.txt
7
+ const rimraf = require("rimraf").sync;
8
+ const _ = require("lodash");
9
+ const common = require("../../../lib/common");
10
+ const optHelp = require("../../helpers/options");
11
+ const ss = require("../../../lib/html-snapshots");
12
+ const utils = require("./utils");
13
+
14
+ const {
15
+ timeout,
16
+ outputDir,
17
+ cleanup,
18
+ cleanupSuccess,
19
+ cleanupError,
20
+ testSuccess,
21
+ bogusFile,
22
+ unexpectedSuccess,
23
+ checkActualFiles
24
+ } = utils;
25
+
26
+ const urls = 3; // must match url # in robots files test fixtures.
28
27
 
29
28
  /**
30
29
  * The robots test suite.
31
30
  */
32
31
  function robotsTests (options) {
33
- var port = options.port;
32
+ const {
33
+ port,
34
+ localRobotsFile,
35
+ browsers
36
+ } = options;
37
+
38
+ // Robots.txt fixtures
39
+ const inputFiles = [
40
+ localRobotsFile,
41
+ `http://localhost:${port}/test_robots.txt`,
42
+ `http://localhost:${port}/test_robots_sitemap.txt`
43
+ ];
34
44
 
35
45
  return function () {
36
- it("should all succeed, no output dir pre-exists", function (done) {
37
- var options = {
38
- source: inputFile,
46
+ function createOptions (newOptions) {
47
+ const options = {
39
48
  hostname: "localhost",
40
- port: port,
41
49
  selector: "#dynamic-content",
42
- outputDir: outputDir,
43
50
  outputDirClean: true,
44
- timeout: timeout
51
+ outputDir,
52
+ timeout,
53
+ port
45
54
  };
46
- var twice = _.after(2, cleanupSuccess.bind(null, done));
47
-
48
- rimraf(outputDir);
49
-
50
- ss.run(optHelp.decorate(options), twice)
51
- .then(testSuccess.bind(null, twice))
52
- .catch(function (e) {
53
- checkActualFiles(e.notCompleted)
54
- .then(function () {
55
- cleanup(done, e);
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
66
+ });
67
+
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
+ });
56
79
  });
57
80
  });
58
- });
59
81
 
60
- it("should all succeed, output dir does pre-exist", function (done) {
61
- var options = {
62
- source: inputFile,
63
- hostname: "localhost",
64
- port: port,
65
- selector: "#dynamic-content",
66
- outputDir: outputDir,
67
- outputDirClean: true,
68
- timeout: timeout
69
- };
70
- var twice = _.after(2, cleanupSuccess.bind(null, done));
71
-
72
- ss.run(optHelp.decorate(options), twice)
73
- .then(testSuccess.bind(null, twice))
74
- .catch(function (e) {
75
- checkActualFiles(e.notCompleted)
76
- .then(function () {
77
- cleanup(done, e);
82
+ it(`should succeed, output dir does pre-exist, ${browser}, ${inputFile}`, function (done) {
83
+ const options = createOptions({
84
+ source: inputFile,
85
+ browser
86
+ });
87
+
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
+ });
78
97
  });
79
98
  });
80
- });
81
99
 
82
- it("should all fail with bad phantomjs process to spawn",
83
- function (done) {
84
- var options = {
85
- source: inputFile,
86
- hostname: "localhost",
87
- port: port,
88
- selector: "#dynamic-content",
89
- outputDir: outputDir,
90
- outputDirClean: true,
91
- phantomjs: bogusFile,
92
- timeout: 1000
93
- };
94
- var twice = _.after(2, cleanupError.bind(null, done, 0));
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
+ });
108
+
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
+ });
95
129
 
96
- ss.run(options, twice)
97
- .then(unexpectedSuccess.bind(null, done))
98
- .catch(twice);
99
- });
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
+ });
100
137
 
101
- it("should all fail, bad remote robots", function (done) {
102
- var options = {
103
- input: "robots",
104
- source: "http://localhost:"+port+"/index.html",
105
- port: port,
106
- selector: "#dynamic-content",
107
- outputDir: outputDir,
108
- outputDirClean: true,
109
- timeout: 6000
110
- };
111
- var twice = _.after(2, cleanupError.bind(null, done, 0));
138
+ const twice = _.after(2, cleanupError.bind(null, done, 0));
112
139
 
113
- ss.run(optHelp.decorate(options), twice)
114
- .then(unexpectedSuccess.bind(null, done))
115
- .catch(twice);
116
- });
140
+ ss.run(optHelp.decorate(options), twice)
141
+ .then(unexpectedSuccess.bind(null, done))
142
+ .catch(twice);
143
+ });
117
144
 
118
- it("should all fail, non-existent selector", function (done) {
119
- var options = {
120
- source: inputFile,
121
- hostname: "localhost",
122
- port: port,
123
- selector: "#dynamic-content-notexist",
124
- outputDir: outputDir,
125
- outputDirClean: true,
126
- timeout: 6000
127
- };
128
- var twice = _.after(2, cleanupError.bind(null, done, 0));
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
+ });
129
152
 
130
- ss.run(optHelp.decorate(options), twice)
131
- .then(unexpectedSuccess.bind(null, done))
132
- .catch(twice);
133
- });
153
+ const twice = _.after(2, cleanupError.bind(null, done, 0));
134
154
 
135
- it("should fail one snapshot, one non-existent selector",
136
- function (done) {
137
- var options = {
138
- source: inputFile,
139
- hostname: "localhost",
140
- port: port,
141
- selector: { "__default": "#dynamic-content", "/": "#dynamic-content-notexist" },
142
- outputDir: outputDir,
143
- outputDirClean: true,
144
- timeout: 6000
145
- };
146
- var twice = _.after(2, cleanupError.bind(null, done, urls - 1));
155
+ ss.run(optHelp.decorate(options), twice)
156
+ .then(unexpectedSuccess.bind(null, done))
157
+ .catch(twice);
158
+ });
147
159
 
148
- ss.run(optHelp.decorate(options), twice)
149
- .then(unexpectedSuccess.bind(null, done))
150
- .catch(twice);
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
+ }
169
+ }
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
+ });
186
+ });
151
187
  });
152
188
  };
153
189
  }
154
190
 
155
191
  module.exports = {
156
192
  testSuite: robotsTests,
157
- inputFile: inputFile,
158
193
  urlCount: urls
159
194
  };
@@ -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 -->
@@ -0,0 +1,13 @@
1
+ User-agent: *
2
+
3
+ Allow: /
4
+ Allow: /contact
5
+ Allow: /services/carpets
6
+
7
+ Disallow: /api/
8
+ Disallow: /vendor/
9
+ Disallow: /fonts/
10
+ Disallow: /images/
11
+
12
+ User-agent: ia_archiver
13
+ Disallow: /
@@ -0,0 +1,15 @@
1
+ User-agent: *
2
+
3
+ Allow: /
4
+ Allow: /contact
5
+ Allow: /services/carpets
6
+
7
+ Disallow: /api/
8
+ Disallow: /vendor/
9
+ Disallow: /fonts/
10
+ Disallow: /images/
11
+
12
+ User-agent: ia_archiver
13
+ Disallow: /
14
+
15
+ Sitemap: http://localhost:8038/test_robots_sitemap.xml
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+
3
+ <urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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">
4
+ <url>
5
+ <loc>http://localhost:8038/</loc>
6
+ <lastmod>2012-08-11T12:16:09+00:00</lastmod>
7
+ <changefreq>daily</changefreq>
8
+ <priority>1.0</priority>
9
+ </url>
10
+ <url>
11
+ <loc>http://localhost:8038/contact</loc>
12
+ <lastmod>2012-11-02T02:53:40+00:00</lastmod>
13
+ <changefreq>weekly</changefreq>
14
+ <priority>0.6</priority>
15
+ </url>
16
+ <url>
17
+ <loc>http://localhost:8038/services/carpets</loc>
18
+ <lastmod>2012-10-19T10:45:23+00:00</lastmod>
19
+ <changefreq>weekly</changefreq>
20
+ <priority>0.6</priority>
21
+ </url>
22
+ </urlset>
@@ -4,80 +4,92 @@
4
4
  * Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
5
5
  */
6
6
  /* global it */
7
- var assert = require("assert");
8
- var path = require("path");
9
- var optHelp = require("../../helpers/options");
10
- var ss = require("../../../lib/html-snapshots");
11
- var utils = require("./utils");
7
+ const assert = require("assert");
8
+ const path = require("path");
9
+ const optHelp = require("../../helpers/options");
10
+ const ss = require("../../../lib/html-snapshots");
11
+ const utils = require("./utils");
12
12
 
13
- // missing destructuring, will write postcard...
14
- var outputDir = utils.outputDir;
15
- var timeout = utils.timeout;
16
- var unexpectedError = utils.unexpectedError;
17
- var unexpectedSuccess = utils.unexpectedSuccess;
18
- var cleanup = utils.cleanup;
19
- var checkActualFiles = utils.checkActualFiles;
13
+ const {
14
+ outputDir,
15
+ timeout,
16
+ unexpectedError,
17
+ unexpectedSuccess,
18
+ cleanup,
19
+ checkActualFiles
20
+ } = utils;
20
21
 
21
22
  // Sitemap-index constants
22
- var sitemapIndexFile = "test_sitemap_index.xml";
23
- var inputFile = path.join(__dirname, "./", sitemapIndexFile);
24
- var urls = 3; // must match the unqiue # of urls in all the sitemap files referenced in sitemap-index.
23
+ const sitemapIndexFile = "test_sitemap_index.xml";
24
+ const inputFile = path.join(__dirname, "./", sitemapIndexFile);
25
+ const urls = 3; // must match the unqiue # of urls in all the sitemap files referenced in sitemap-index.
25
26
 
26
27
  function getClass (obj) {
27
- var string = Object.prototype.toString.call(obj);
28
- var m = /\[object ([^\]]+)/.exec(string);
28
+ const string = Object.prototype.toString.call(obj);
29
+ const m = /\[object ([^\]]+)/.exec(string);
29
30
  return m && m[1];
30
31
  }
31
32
 
32
33
  function sitemapIndexTests (options) {
33
- var port = options.port;
34
+ const {
35
+ port,
36
+ browsers
37
+ } = options;
34
38
 
35
- return function () {
36
- it("should succeed for typical sitemap-index usage", function (done) {
37
- var options = {
38
- source: "http://localhost:"+port+"/"+sitemapIndexFile,
39
- input: "sitemap-index",
40
- selector: "#dynamic-content",
41
- outputDir: outputDir,
42
- outputDirClean: true,
43
- timeout: timeout
44
- };
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
+ }
45
54
 
46
- ss.run(optHelp.decorate(options))
47
- .then(function (completed) {
48
- var assertionError;
49
- try {
50
- assert.equal(getClass(completed), "Array");
51
- assert.equal(completed.length, urls);
52
- } catch (e) {
53
- assertionError = e;
54
- }
55
- cleanup(done, assertionError);
56
- })
57
- .catch(function (err) {
58
- checkActualFiles(err.notCompleted)
59
- .then(function () {
60
- cleanup(done, err || unexpectedError);
61
- });
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
62
60
  });
63
- });
64
61
 
65
- it("should fail fast for bad sitemap url", function (done) {
66
- var sitemapIndexFile3 = path.basename(sitemapIndexFile, ".xml") + "-3" +
67
- path.extname(sitemapIndexFile);
68
- var options = {
69
- source: "http://localhost:" + port + "/" + sitemapIndexFile3,
70
- input: "sitemap-index",
71
- selector: "#dynamic-content",
72
- outputDir: outputDir,
73
- outputDirClean: true,
74
- timeout: timeout
75
- };
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
+ });
80
+
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
87
+ });
76
88
 
77
89
  ss.run(optHelp.decorate(options))
78
90
  .then(unexpectedSuccess)
79
- .catch(function (err) {
80
- var assertionError;
91
+ .catch(err => {
92
+ let assertionError;
81
93
  try {
82
94
  assert.equal(getClass(err.notCompleted), "Array");
83
95
  // fails fast:
@@ -87,44 +99,42 @@ function sitemapIndexTests (options) {
87
99
  }
88
100
  cleanup(done, assertionError);
89
101
  });
90
- });
91
-
92
- it("should eventually fail for bad page url", function (done) {
93
- var eventually = 1000;
94
- var sitemapIndexFile2 = path.basename(sitemapIndexFile, ".xml") + "-2" +
95
- path.extname(sitemapIndexFile);
96
- var options = {
97
- source: "http://localhost:" + port + "/" + sitemapIndexFile2,
98
- input: "sitemap-index",
99
- selector: "#dynamic-content",
100
- outputDir: outputDir,
101
- outputDirClean: true,
102
- timeout: {
103
- "http://localhost:8040/services/bad": eventually,
104
- __default: timeout
105
- }
106
- };
102
+ });
107
103
 
108
- ss.run(optHelp.decorate(options))
109
- .then(unexpectedSuccess)
110
- .catch(function (err) {
111
- var assertionError;
112
- try {
113
- assert.equal(getClass(err.completed), "Array");
114
- assert.equal(err.completed.length, urls - 1);
115
- assert.equal(getClass(err.notCompleted), "Array");
116
- assert.equal(err.notCompleted.length, 1);
117
- } catch (e) {
118
- assertionError = e;
119
- }
120
- 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
121
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
+ });
122
132
  });
123
133
  };
124
134
  }
125
135
 
126
136
  module.exports = {
127
137
  testSuite: sitemapIndexTests,
128
- inputFile: inputFile,
129
- urlCount: urls
138
+ urlCount: urls,
139
+ inputFile
130
140
  };