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
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "html-snapshots-example",
3
+ "version": "0.1.0",
4
+ "author": "Alex Grant <alex@localnerve.com>",
5
+ "description": "An example using html-snapshots",
6
+ "scripts": {
7
+ "start": "node ./snapshot.js"
8
+ },
9
+ "dependencies": {
10
+ "html-snapshots": "^1.0.0"
11
+ }
12
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Debug puppeteer processing of a page on a sample website.
3
+ *
4
+ * The debug flag applies to all pages, so best to use it to debug one problem page at a time separately.
5
+ *
6
+ * Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
7
+ */
8
+ const path = require("path");
9
+ const util = require("util");
10
+ const htmlSnapshots = require("html-snapshots");
11
+
12
+ htmlSnapshots.run({
13
+ source: [ "https://google.com" ],
14
+ outputDir: path.join(__dirname, "./tmp"),
15
+ outputDirClean: true,
16
+ selector: "body",
17
+ timeout: 60000,
18
+ debug: {
19
+ flag: true,
20
+ slowMo: 2000
21
+ }
22
+ })
23
+ .then(completed => {
24
+ console.log("completed snapshots:");
25
+ console.log(util.inspect(completed));
26
+ })
27
+ .catch(error => {
28
+ console.error("error occurred");
29
+ console.error(util.inspect(error));
30
+ });