html-snapshots 1.3.2 → 1.5.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/lib/common/index.js +57 -3
- package/lib/common/sitemap/sitemap-collection.js +3 -2
- package/lib/common/sitemap/sitemap-index.js +1 -4
- package/lib/common/sitemap/sitemap.js +15 -13
- package/lib/html-snapshots.js +5 -6
- package/lib/input-generators/_base.js +5 -5
- package/package.json +5 -6
- package/.c8rc.json +0 -5
- package/.eslintignore +0 -5
- package/.eslintrc.json +0 -16
- package/.github/issue_template.md +0 -16
- package/.github/workflows/verify.yml +0 -32
- package/docs/example-heroku-redis.md +0 -43
- package/docs/notes.md +0 -42
- package/examples/README.md +0 -149
- package/examples/custom/README.md +0 -22
- package/examples/custom/myFilter.js +0 -22
- package/examples/custom/package-lock.json +0 -2804
- package/examples/custom/package.json +0 -12
- package/examples/custom/snapshot.js +0 -28
- package/examples/debug-phantomjs/README.md +0 -38
- package/examples/debug-phantomjs/package-lock.json +0 -2922
- package/examples/debug-phantomjs/package.json +0 -12
- package/examples/debug-phantomjs/snapshot.js +0 -60
- package/examples/debug-puppeteer/README.md +0 -18
- package/examples/debug-puppeteer/package-lock.json +0 -2804
- package/examples/debug-puppeteer/package.json +0 -12
- package/examples/debug-puppeteer/snapshot.js +0 -30
- package/examples/html5rocks/README.md +0 -22
- package/examples/html5rocks/package-lock.json +0 -3218
- package/examples/html5rocks/package.json +0 -12
- package/examples/html5rocks/snapshot.js +0 -59
- package/examples/process-limit/README.md +0 -24
- package/examples/process-limit/package-lock.json +0 -2830
- package/examples/process-limit/package.json +0 -12
- package/examples/process-limit/snapshot.js +0 -30
- package/examples/simple-promise/README.md +0 -20
- package/examples/simple-promise/package-lock.json +0 -2830
- package/examples/simple-promise/package.json +0 -12
- package/examples/simple-promise/snapshot.js +0 -30
- package/examples/sitemap-index/README.md +0 -20
- package/examples/sitemap-index/package-lock.json +0 -2830
- package/examples/sitemap-index/package.json +0 -12
- package/examples/sitemap-index/snapshot.js +0 -34
- package/examples/verbose/README.md +0 -22
- package/examples/verbose/package-lock.json +0 -2805
- package/examples/verbose/package.json +0 -12
- package/examples/verbose/snapshot.js +0 -34
- package/test/helpers/options.js +0 -55
- package/test/helpers/result.js +0 -32
- package/test/helpers/sitemap.js +0 -130
- package/test/mocha/async/test.js +0 -416
- package/test/mocha/browsers/puppeteer.js +0 -129
- package/test/mocha/browsers/server/index.html +0 -9
- package/test/mocha/browsers/test.js +0 -11
- package/test/mocha/common/helpers.js +0 -87
- package/test/mocha/common/test.js +0 -188
- package/test/mocha/html-snapshots/basics.js +0 -88
- package/test/mocha/html-snapshots/myFilter.js +0 -10
- package/test/mocha/html-snapshots/phantomjs-options.js +0 -156
- package/test/mocha/html-snapshots/process-limit.js +0 -156
- package/test/mocha/html-snapshots/puppeteer.js +0 -47
- package/test/mocha/html-snapshots/robots.js +0 -194
- package/test/mocha/html-snapshots/server/contact/index.html +0 -57
- package/test/mocha/html-snapshots/server/favicon.ico +0 -0
- package/test/mocha/html-snapshots/server/fonts/facebolf-webfont.eot +0 -0
- package/test/mocha/html-snapshots/server/fonts/facebolf-webfont.svg +0 -220
- package/test/mocha/html-snapshots/server/fonts/facebolf-webfont.ttf +0 -0
- package/test/mocha/html-snapshots/server/fonts/facebolf-webfont.woff +0 -0
- package/test/mocha/html-snapshots/server/images/ajax-loader.gif +0 -0
- package/test/mocha/html-snapshots/server/images/art1.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpet.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpets/carpet1.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpets/carpet1_th.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpets/carpet2.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpets/carpet2_th.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpets/carpet3.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpets/carpet3_th.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpets/carpet4.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/carpets/carpet4_th.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/floor.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/bullets.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/left-arrow-small.png +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/left-arrow.png +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/loading.gif +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/mask-black.png +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/pause-black.png +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/right-arrow-small.png +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/right-arrow.png +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/rotator-black.png +0 -0
- package/test/mocha/html-snapshots/server/images/foundation/orbit/timer-black.png +0 -0
- package/test/mocha/html-snapshots/server/images/home-sprite/certification.png +0 -0
- package/test/mocha/html-snapshots/server/images/home-sprite/cleantrust.png +0 -0
- package/test/mocha/html-snapshots/server/images/home-sprite/institute.png +0 -0
- package/test/mocha/html-snapshots/server/images/home-sprite-s1a48fdbd81.png +0 -0
- package/test/mocha/html-snapshots/server/images/logo-300.png +0 -0
- package/test/mocha/html-snapshots/server/images/slider1-lg.jpg +0 -0
- package/test/mocha/html-snapshots/server/images/slider1.jpg +0 -0
- package/test/mocha/html-snapshots/server/index.css +0 -1
- package/test/mocha/html-snapshots/server/index.html +0 -57
- package/test/mocha/html-snapshots/server/nojq/index.html +0 -46
- package/test/mocha/html-snapshots/server/pjsopts/index.html +0 -55
- package/test/mocha/html-snapshots/server/public/page-sitemap.xml +0 -16
- package/test/mocha/html-snapshots/server/public/wordpress/category-sitemap.xml +0 -13
- package/test/mocha/html-snapshots/server/public/wordpress/page-sitemap.xml +0 -16
- package/test/mocha/html-snapshots/server/public/wordpress/post-sitemap.xml +0 -27
- package/test/mocha/html-snapshots/server/public/wordpress/post_tag-sitemap.xml +0 -17
- package/test/mocha/html-snapshots/server/public/wordpress/product-sitemap.xml +0 -13
- package/test/mocha/html-snapshots/server/public/wordpress-2/category-sitemap.xml +0 -13
- package/test/mocha/html-snapshots/server/public/wordpress-2/page-sitemap.xml +0 -16
- package/test/mocha/html-snapshots/server/public/wordpress-2/post-sitemap.xml +0 -27
- package/test/mocha/html-snapshots/server/public/wordpress-2/post_tag-sitemap.xml +0 -17
- package/test/mocha/html-snapshots/server/public/wordpress-2/product-sitemap.xml +0 -13
- package/test/mocha/html-snapshots/server/require.js +0 -1
- package/test/mocha/html-snapshots/server/services/carpets/index.html +0 -57
- package/test/mocha/html-snapshots/server/test_robots.txt +0 -13
- package/test/mocha/html-snapshots/server/test_robots_sitemap.txt +0 -15
- package/test/mocha/html-snapshots/server/test_robots_sitemap.xml +0 -22
- package/test/mocha/html-snapshots/server/test_sitemap_index-2.xml +0 -25
- package/test/mocha/html-snapshots/server/test_sitemap_index-3.xml +0 -25
- package/test/mocha/html-snapshots/server/test_sitemap_index.xml +0 -25
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/extras/custom-validity.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/extras/modernizr-custom.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/extras/mousepress.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/polyfiller.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvas/canvas2png.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvas/flashcanvas.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvas/flashcanvas.swf +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvas/proxy.php +0 -73
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvas/save.php +0 -49
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvasPro/canvas2png.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvasPro/flash10canvas.swf +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvasPro/flash9canvas.swf +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvasPro/flashcanvas.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvasPro/proxy.php +0 -73
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/FlashCanvasPro/save.php +0 -49
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/1.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/10.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/11.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/12.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/13.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/14.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/15.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/16.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/17.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/18.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/19.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/2.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/20.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/21.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/22.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/23.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/24.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/25.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/26.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/27.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/3.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/4.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/5.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/59.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/6.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/7.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/8.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/combos/9.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/details.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/dom-extend.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/es5.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/excanvas.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/form-core.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/form-datalist.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/form-message.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/form-native-extend.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/form-number-date-api.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/form-number-date-ui.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/form-shim-extend.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/geolocation.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-ar.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-ch-ZN.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-de.txt +0 -33
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-el.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-en.txt +0 -34
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-es.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-fr.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-he.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-hi.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-hu.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-it.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-ja.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-nl.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-pt-PT.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-ru.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/i18n/errormessages-sv.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/json-storage.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/jwplayer/license.txt +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/jwplayer/player.swf +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/jwplayer/readme.html +0 -87
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/mediaelement-core.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/mediaelement-jaris.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/mediaelement-native-fix.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/mediaelement-swf.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/mediaelement-yt.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/styles/details-arrows.png +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/styles/forms.png +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/styles/polyfill-loader.gif +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/styles/shim.css +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/swf/JarisFLVPlayer.swf +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/swf/jwwebshims.swf +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/swf/localStorage.swf +0 -0
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/track-ui.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/libs/webshim/minified/shims/track.js +0 -1
- package/test/mocha/html-snapshots/server/vendor/js/plugins/cload.js +0 -49
- package/test/mocha/html-snapshots/server/vendor/js/plugins/modernizr.js +0 -4
- package/test/mocha/html-snapshots/server/vendor/js/plugins/oldie.js +0 -74
- package/test/mocha/html-snapshots/sitemap-index.js +0 -140
- package/test/mocha/html-snapshots/sitemap.js +0 -104
- package/test/mocha/html-snapshots/snapshot-scripts.js +0 -206
- package/test/mocha/html-snapshots/test.js +0 -105
- package/test/mocha/html-snapshots/test_robots.txt +0 -13
- package/test/mocha/html-snapshots/test_sitemap.xml +0 -22
- package/test/mocha/html-snapshots/use-jquery.js +0 -144
- package/test/mocha/html-snapshots/utils.js +0 -200
- package/test/mocha/input-generators/server/public/wordpress/category-sitemap.xml +0 -13
- package/test/mocha/input-generators/server/public/wordpress/page-sitemap.xml +0 -16
- package/test/mocha/input-generators/server/public/wordpress/post-sitemap.xml +0 -55
- package/test/mocha/input-generators/server/public/wordpress/post_tag-sitemap.xml +0 -25
- package/test/mocha/input-generators/server/public/wordpress/product-sitemap.xml +0 -13
- package/test/mocha/input-generators/server/test_robots.txt +0 -15
- package/test/mocha/input-generators/server/test_robots_bad.txt +0 -11
- package/test/mocha/input-generators/server/test_robots_sitemap.txt +0 -17
- package/test/mocha/input-generators/server/test_robots_sitemap_bad.txt +0 -17
- package/test/mocha/input-generators/server/test_robots_sitemap_multi.txt +0 -18
- package/test/mocha/input-generators/server/test_sitemap.xml +0 -34
- package/test/mocha/input-generators/server/test_sitemap.xml.gz +0 -0
- package/test/mocha/input-generators/server/test_sitemap_bad.xml.gz +0 -0
- package/test/mocha/input-generators/server/test_sitemap_index.xml +0 -25
- package/test/mocha/input-generators/server/test_sitemap_index.xml.gz +0 -0
- package/test/mocha/input-generators/server/test_sitemap_index_empty.xml +0 -3
- package/test/mocha/input-generators/server/test_sitemap_index_malformed.xml +0 -2
- package/test/mocha/input-generators/sitemap-index.js +0 -87
- package/test/mocha/input-generators/sitemap.js +0 -320
- package/test/mocha/input-generators/test.js +0 -1447
- package/test/mocha/input-generators/test_line.txt +0 -5
- package/test/mocha/input-generators/test_robots.txt +0 -15
- package/test/mocha/input-generators/test_robots_bad.txt +0 -11
- package/test/mocha/input-generators/test_robots_sitemap.txt +0 -17
- package/test/mocha/input-generators/test_robots_sitemap_bad.txt +0 -17
- package/test/mocha/input-generators/test_robots_sitemap_multi.txt +0 -18
- package/test/mocha/input-generators/test_sitemap.xml +0 -34
- package/test/mocha/input-generators/test_sitemap.xml.gz +0 -0
- package/test/mocha/input-generators/test_sitemap_bad.xml.gz +0 -0
- package/test/mocha/input-generators/test_sitemap_index.xml +0 -25
- package/test/mocha/input-generators/test_sitemap_index.xml.gz +0 -0
- package/test/server/index.js +0 -32
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tests that target the puppeteer script specifically.
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
|
-
*/
|
|
6
|
-
/* global before, it */
|
|
7
|
-
const assert = require("assert");
|
|
8
|
-
const path = require("path");
|
|
9
|
-
const rimraf = require("rimraf").sync;
|
|
10
|
-
const spawn = require("child_process").spawn;
|
|
11
|
-
const server = require("../../server");
|
|
12
|
-
|
|
13
|
-
const outputDir = path.join(__dirname, "tmp");
|
|
14
|
-
const port = 9340;
|
|
15
|
-
|
|
16
|
-
function puppeteerTests () {
|
|
17
|
-
const snapshotScript = path.resolve(__dirname, '../../../lib/puppeteer/index.js');
|
|
18
|
-
const outputFile = path.join(outputDir, "snapshot.html");
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Launch the puppeteer script as a process.
|
|
22
|
-
*
|
|
23
|
-
* @param {Array} args - array of puppeteer args
|
|
24
|
-
*/
|
|
25
|
-
function spawnPuppeteer (args, done) {
|
|
26
|
-
const cp = spawn(
|
|
27
|
-
snapshotScript,
|
|
28
|
-
args
|
|
29
|
-
, { cwd: process.cwd(), stdio: "inherit", detached: true }
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
cp.on("exit", code => {
|
|
33
|
-
if (code !== 0) {
|
|
34
|
-
return done(new Error(`error exit code: ${code}`));
|
|
35
|
-
}
|
|
36
|
-
done();
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return function () {
|
|
41
|
-
before(function() {
|
|
42
|
-
server.start(path.join(__dirname, "./server"), port);
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("should succeed with minimal args", function (done) {
|
|
46
|
-
this.timeout(4000);
|
|
47
|
-
|
|
48
|
-
rimraf(outputDir);
|
|
49
|
-
|
|
50
|
-
spawnPuppeteer([
|
|
51
|
-
outputFile,
|
|
52
|
-
`http://localhost:${port}/`,
|
|
53
|
-
"body"
|
|
54
|
-
], done);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
it("should succeed with stringified puppeteerLaunchOptions", function (done) {
|
|
58
|
-
this.timeout(4000);
|
|
59
|
-
rimraf(outputDir);
|
|
60
|
-
|
|
61
|
-
// override the debug options to prove stringified launch opts worked.
|
|
62
|
-
const puppeteerLaunchOptions = {
|
|
63
|
-
headless: true,
|
|
64
|
-
devTools: false
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
spawnPuppeteer([
|
|
68
|
-
outputFile,
|
|
69
|
-
`http://localhost:${port}/`,
|
|
70
|
-
"body",
|
|
71
|
-
4000,
|
|
72
|
-
"false",
|
|
73
|
-
"true",
|
|
74
|
-
10,
|
|
75
|
-
JSON.stringify(puppeteerLaunchOptions)
|
|
76
|
-
], done);
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it("should fail if insufficient input args", function (done) {
|
|
80
|
-
rimraf(outputDir);
|
|
81
|
-
|
|
82
|
-
spawnPuppeteer([
|
|
83
|
-
outputFile,
|
|
84
|
-
"http://someurl.domain/path/resource"
|
|
85
|
-
], e => {
|
|
86
|
-
const msg = "expected process error";
|
|
87
|
-
assert.ok(e, msg);
|
|
88
|
-
done(e ? undefined : new Error(msg));
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it("should fail with bad url", function (done) {
|
|
93
|
-
rimraf(outputDir);
|
|
94
|
-
|
|
95
|
-
spawnPuppeteer([
|
|
96
|
-
outputFile,
|
|
97
|
-
"http://nonexistent.domain/path/resource",
|
|
98
|
-
"body",
|
|
99
|
-
1000
|
|
100
|
-
], e => {
|
|
101
|
-
const msg = "expected process error";
|
|
102
|
-
assert.ok(e, msg);
|
|
103
|
-
done(e ? undefined : new Error(msg));
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("should launch debugging", function (done) {
|
|
108
|
-
const timeout = 5000;
|
|
109
|
-
this.timeout(timeout);
|
|
110
|
-
|
|
111
|
-
rimraf(outputDir);
|
|
112
|
-
|
|
113
|
-
spawnPuppeteer([
|
|
114
|
-
outputFile,
|
|
115
|
-
`http://localhost:${port}/`,
|
|
116
|
-
"body",
|
|
117
|
-
timeout - 1000,
|
|
118
|
-
"false",
|
|
119
|
-
"true",
|
|
120
|
-
10
|
|
121
|
-
], done);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
module.exports = {
|
|
128
|
-
testSuite: puppeteerTests
|
|
129
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* browser process specific tests
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
|
-
*/
|
|
6
|
-
/* global describe */
|
|
7
|
-
const puppeteer = require("./puppeteer");
|
|
8
|
-
|
|
9
|
-
describe("browser process tests", function () {
|
|
10
|
-
describe("puppeteer", puppeteer.testSuite());
|
|
11
|
-
});
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Helpers tests.
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
|
-
*/
|
|
6
|
-
/* global describe, it */
|
|
7
|
-
var assert = require("assert");
|
|
8
|
-
var resHelper = require("../../helpers/result");
|
|
9
|
-
|
|
10
|
-
describe("helpers", function() {
|
|
11
|
-
|
|
12
|
-
describe("result", function() {
|
|
13
|
-
|
|
14
|
-
describe("mustBeError", function() {
|
|
15
|
-
|
|
16
|
-
it("should succeed if get Error", function() {
|
|
17
|
-
resHelper.mustBeError(new Error());
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it("should succeed if get String", function() {
|
|
21
|
-
resHelper.mustBeError("test error");
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("should fail if null string", function() {
|
|
25
|
-
var err;
|
|
26
|
-
try {
|
|
27
|
-
resHelper.mustBeError("");
|
|
28
|
-
} catch(e) {
|
|
29
|
-
err = e;
|
|
30
|
-
}
|
|
31
|
-
assert.notStrictEqual(typeof err, "undefined");
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("should fail if false", function() {
|
|
35
|
-
var err;
|
|
36
|
-
try {
|
|
37
|
-
resHelper.mustBeError(false);
|
|
38
|
-
} catch(e) {
|
|
39
|
-
err = e;
|
|
40
|
-
}
|
|
41
|
-
assert.notStrictEqual(typeof err, "undefined");
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("should fail if undefined", function() {
|
|
45
|
-
var err;
|
|
46
|
-
try {
|
|
47
|
-
resHelper.mustBeError();
|
|
48
|
-
} catch(e) {
|
|
49
|
-
err = e;
|
|
50
|
-
}
|
|
51
|
-
assert.notStrictEqual(typeof err, "undefined");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("should fail if NaN", function() {
|
|
55
|
-
var err;
|
|
56
|
-
try {
|
|
57
|
-
resHelper.mustBeError(NaN);
|
|
58
|
-
} catch(e) {
|
|
59
|
-
err = e;
|
|
60
|
-
}
|
|
61
|
-
assert.notStrictEqual(typeof err, "undefined");
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("should fail if 0", function() {
|
|
65
|
-
var err;
|
|
66
|
-
try {
|
|
67
|
-
resHelper.mustBeError(0);
|
|
68
|
-
} catch(e) {
|
|
69
|
-
err = e;
|
|
70
|
-
}
|
|
71
|
-
assert.notStrictEqual(typeof err, "undefined");
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("should fail if null", function() {
|
|
75
|
-
var err;
|
|
76
|
-
try {
|
|
77
|
-
resHelper.mustBeError(null);
|
|
78
|
-
} catch(e) {
|
|
79
|
-
err = e;
|
|
80
|
-
}
|
|
81
|
-
assert.notStrictEqual(typeof err, "undefined");
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
});
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Common module tests.
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
|
-
*/
|
|
6
|
-
/* global describe, it */
|
|
7
|
-
var assert = require("assert");
|
|
8
|
-
var path = require("path");
|
|
9
|
-
var common = require("../../../lib/common");
|
|
10
|
-
|
|
11
|
-
describe("common", function () {
|
|
12
|
-
|
|
13
|
-
describe("ensure", function () {
|
|
14
|
-
|
|
15
|
-
it("should return the options if no defaults specified", function () {
|
|
16
|
-
var options = { one: "one", two: "two", three: "three" };
|
|
17
|
-
var result = common.ensure(options);
|
|
18
|
-
assert.equal(result.toString(), options.toString());
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("should return the result options", function () {
|
|
22
|
-
var defaults = { one: "two", two: "three", three: "four" };
|
|
23
|
-
var options = { one: "one", two: "two", three: "three" };
|
|
24
|
-
var result = common.ensure(options, defaults);
|
|
25
|
-
assert.equal(result.toString(), options.toString());
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("should not copy defaults when specified in options", function () {
|
|
29
|
-
var defaults = { one: "two", two: "three", three: "four" };
|
|
30
|
-
var options = { one: "one", two: "two", three: "three" };
|
|
31
|
-
common.ensure(options, defaults);
|
|
32
|
-
assert.equal("one", options.one);
|
|
33
|
-
assert.equal("two", options.two);
|
|
34
|
-
assert.equal("three", options.three);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("should copy defaults when not specified in options", function () {
|
|
38
|
-
var defaults = { one: "two", two: "three", three: "four" };
|
|
39
|
-
var options = { one: "one", two: "two" };
|
|
40
|
-
common.ensure(options, defaults);
|
|
41
|
-
assert.equal("one", options.one);
|
|
42
|
-
assert.equal("two", options.two);
|
|
43
|
-
assert.equal("four", options.three);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe("isUrl", function () {
|
|
48
|
-
|
|
49
|
-
it("should detect an http url", function () {
|
|
50
|
-
var result = common.isUrl("http://whatever.com/");
|
|
51
|
-
assert.equal(true, result);
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("should not detect a file", function () {
|
|
55
|
-
var result = common.isUrl(path.join(__dirname, __filename));
|
|
56
|
-
assert.equal(false, result);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("should not detect an object", function () {
|
|
60
|
-
var result = common.isUrl({ url: "bogus" });
|
|
61
|
-
assert.equal(false, result);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
describe("prependMsgToErr", function () {
|
|
66
|
-
|
|
67
|
-
it("should return undefined if given falsy error", function () {
|
|
68
|
-
var result = common.prependMsgToErr(undefined, "message", true);
|
|
69
|
-
|
|
70
|
-
assert.equal(result, undefined);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("should return same error if given error and no message", function () {
|
|
74
|
-
// These need to have the same message.
|
|
75
|
-
var error = new Error("my test error");
|
|
76
|
-
var input = new Error("my test error");
|
|
77
|
-
|
|
78
|
-
var result = common.prependMsgToErr(input);
|
|
79
|
-
|
|
80
|
-
assert.deepEqual(result, error);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it("should quote the message when asked", function () {
|
|
84
|
-
var msg = "my message";
|
|
85
|
-
var result = common.prependMsgToErr(new Error("my test error"), msg, true);
|
|
86
|
-
|
|
87
|
-
assert.equal(result.message.indexOf("'"+msg+"'") > -1, true);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it("should not quote a message when asked", function () {
|
|
91
|
-
var msg = "my message";
|
|
92
|
-
var result = common.prependMsgToErr(new Error("my test error"), msg);
|
|
93
|
-
|
|
94
|
-
assert.equal(result.message.indexOf("'"+msg+"'") === -1, true);
|
|
95
|
-
assert.equal(result.message.indexOf(msg) > -1, true);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
it("should make an error if string was given", function () {
|
|
99
|
-
var input = "my test error";
|
|
100
|
-
var msg = "my message";
|
|
101
|
-
var result = common.prependMsgToErr(input, msg, true);
|
|
102
|
-
|
|
103
|
-
assert.equal(result instanceof Error, true);
|
|
104
|
-
assert.equal(result.message.indexOf("'"+msg+"'") > -1, true);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("should prepend message to error", function () {
|
|
108
|
-
var msg = "my message";
|
|
109
|
-
var errMsg = "my test error";
|
|
110
|
-
var result = common.prependMsgToErr(new Error(errMsg), msg);
|
|
111
|
-
|
|
112
|
-
var resultMessage = result.message.split(": ");
|
|
113
|
-
|
|
114
|
-
assert.equal(resultMessage.length > 1, true);
|
|
115
|
-
assert.equal(resultMessage[0], msg);
|
|
116
|
-
assert.equal(resultMessage[1], errMsg);
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
describe("checkResponse", function () {
|
|
121
|
-
|
|
122
|
-
it("should reject a non 200 response", function() {
|
|
123
|
-
var result = common.checkResponse({ statusCode: 206 }, "doesntmatter");
|
|
124
|
-
assert.notEqual(false, result);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
it("should reject for missing content type", function() {
|
|
128
|
-
var result = common.checkResponse({
|
|
129
|
-
statusCode: 200,
|
|
130
|
-
headers: {}
|
|
131
|
-
}, "any");
|
|
132
|
-
assert.notEqual(false, result);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
it("should reject for bad content type, single", function() {
|
|
136
|
-
var result = common.checkResponse({
|
|
137
|
-
statusCode: 200,
|
|
138
|
-
headers: {
|
|
139
|
-
"content-type": "text/plain"
|
|
140
|
-
}
|
|
141
|
-
}, "text/xml");
|
|
142
|
-
assert.notEqual(false, result);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
it("should reject for bad content type, multiple", function() {
|
|
146
|
-
var result = common.checkResponse({
|
|
147
|
-
statusCode: 200,
|
|
148
|
-
headers: {
|
|
149
|
-
"content-type": "text/plain"
|
|
150
|
-
}
|
|
151
|
-
}, ["text/xml", "application/xml"]);
|
|
152
|
-
assert.notEqual(false, result);
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it("should accept for good content type, single", function() {
|
|
156
|
-
var contentType = "text/plain";
|
|
157
|
-
var result = common.checkResponse({
|
|
158
|
-
statusCode: 200,
|
|
159
|
-
headers: {
|
|
160
|
-
"content-type": contentType
|
|
161
|
-
}
|
|
162
|
-
}, contentType);
|
|
163
|
-
assert.equal(false, result);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it("should accept for good content type, multiple, first", function() {
|
|
167
|
-
var contentType = "text/xml";
|
|
168
|
-
var result = common.checkResponse({
|
|
169
|
-
statusCode: 200,
|
|
170
|
-
headers: {
|
|
171
|
-
"content-type": contentType
|
|
172
|
-
}
|
|
173
|
-
}, [contentType, "application/xml"]);
|
|
174
|
-
assert.equal(false, result);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it("should accept for good content type, multiple, last", function() {
|
|
178
|
-
var contentType = "text/xml";
|
|
179
|
-
var result = common.checkResponse({
|
|
180
|
-
statusCode: 200,
|
|
181
|
-
headers: {
|
|
182
|
-
"content-type": contentType
|
|
183
|
-
}
|
|
184
|
-
}, ["application/xml", contentType]);
|
|
185
|
-
assert.equal(false, result);
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
});
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Basic library tests.
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
|
-
*/
|
|
6
|
-
/* global it */
|
|
7
|
-
const assert = require("assert");
|
|
8
|
-
const _ = require("lodash");
|
|
9
|
-
const fs = require("fs");
|
|
10
|
-
const path = require("path");
|
|
11
|
-
const ss = require("../../../lib/html-snapshots");
|
|
12
|
-
const utils = require("./utils");
|
|
13
|
-
const optHelp = require("../../helpers/options");
|
|
14
|
-
|
|
15
|
-
// missing destructuring, will write postcard...
|
|
16
|
-
const {
|
|
17
|
-
bogusFile,
|
|
18
|
-
cleanupError,
|
|
19
|
-
unexpectedSuccess
|
|
20
|
-
} = utils;
|
|
21
|
-
|
|
22
|
-
function basicTests (options) {
|
|
23
|
-
const {
|
|
24
|
-
browsers
|
|
25
|
-
} = options;
|
|
26
|
-
return function () {
|
|
27
|
-
browsers.forEach(browser => {
|
|
28
|
-
it(`no arguments should fail - ${browser}`, function (done) {
|
|
29
|
-
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
30
|
-
|
|
31
|
-
ss.run(optHelp.decorate({
|
|
32
|
-
browser
|
|
33
|
-
}), twice)
|
|
34
|
-
.then(unexpectedSuccess.bind(null, done))
|
|
35
|
-
.catch(twice);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it(`invalid source should fail - ${browser}`, function (done) {
|
|
39
|
-
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
40
|
-
|
|
41
|
-
ss.run(optHelp.decorate({
|
|
42
|
-
source: bogusFile,
|
|
43
|
-
browser
|
|
44
|
-
}), twice)
|
|
45
|
-
.then(unexpectedSuccess.bind(null, done))
|
|
46
|
-
.catch(twice);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it(`should clean the output directory when specified - ${browser}`, function (done) {
|
|
50
|
-
const dir = path.join(__dirname, "./tmpdir");
|
|
51
|
-
const file = path.join(dir, "somefile.txt");
|
|
52
|
-
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
53
|
-
|
|
54
|
-
fs.mkdirSync(dir);
|
|
55
|
-
fs.writeFileSync(file, "some data");
|
|
56
|
-
assert.doesNotThrow(fs.accessSync.bind(null, dir));
|
|
57
|
-
|
|
58
|
-
ss.run(optHelp.decorate({
|
|
59
|
-
source: bogusFile,
|
|
60
|
-
outputDir: dir,
|
|
61
|
-
outputDirClean: true,
|
|
62
|
-
browser
|
|
63
|
-
}), twice)
|
|
64
|
-
.then(unexpectedSuccess.bind(null, done))
|
|
65
|
-
.catch(twice);
|
|
66
|
-
|
|
67
|
-
assert.throws(fs.accessSync.bind(null, dir));
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
it(`default snapshot script should exist - ${browser}`, function (done) {
|
|
71
|
-
const options = { source: "./bogus/file.txt", browser };
|
|
72
|
-
const twice = _.after(2, cleanupError.bind(null, done, 0));
|
|
73
|
-
|
|
74
|
-
const result = ss.run(optHelp.decorate(options), twice);
|
|
75
|
-
|
|
76
|
-
assert.doesNotThrow(fs.accessSync.bind(null, options.snapshotScript));
|
|
77
|
-
|
|
78
|
-
result
|
|
79
|
-
.then(unexpectedSuccess.bind(null, done))
|
|
80
|
-
.catch(twice);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
module.exports = {
|
|
87
|
-
testSuite: basicTests
|
|
88
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-test, custom filter script.
|
|
3
|
-
* Adds a custom tag onto the body.
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
6
|
-
*/
|
|
7
|
-
module.exports = function(content) {
|
|
8
|
-
console.log("IN THE CUSTOMFILTER");
|
|
9
|
-
return content.replace(/<body\b\s*/i, "<body data-someattrZZQy=\"true\" ");
|
|
10
|
-
};
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Library tests focused on the phantomjsOptions option.
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2013 - 2022, Alex Grant, LocalNerve, contributors
|
|
5
|
-
*/
|
|
6
|
-
/* global it */
|
|
7
|
-
const path = require("path");
|
|
8
|
-
const fs = require("fs");
|
|
9
|
-
const rimraf = require("rimraf").sync;
|
|
10
|
-
const utils = require("./utils");
|
|
11
|
-
const optHelp = require("../../helpers/options");
|
|
12
|
-
const resHelp = require("../../helpers/result");
|
|
13
|
-
const ss = require("../../../lib/html-snapshots");
|
|
14
|
-
|
|
15
|
-
const {
|
|
16
|
-
timeout,
|
|
17
|
-
outputDir,
|
|
18
|
-
cleanup,
|
|
19
|
-
unexpectedError,
|
|
20
|
-
unexpectedSuccess,
|
|
21
|
-
checkActualFiles
|
|
22
|
-
} = utils;
|
|
23
|
-
|
|
24
|
-
const outputBase = path.resolve(outputDir, "..");
|
|
25
|
-
const cookiesFile = path.join(outputBase, "cookies.txt");
|
|
26
|
-
|
|
27
|
-
function phantomjsOptionsTests (options) {
|
|
28
|
-
const {
|
|
29
|
-
port
|
|
30
|
-
} = options;
|
|
31
|
-
|
|
32
|
-
function createOptions (newOptions) {
|
|
33
|
-
const defaultOptions = {
|
|
34
|
-
input: "array",
|
|
35
|
-
source: [ `http://localhost:${port}/pjsopts` ],
|
|
36
|
-
outputDir,
|
|
37
|
-
outputDirClean: false,
|
|
38
|
-
selector: ".content-complete",
|
|
39
|
-
timeout,
|
|
40
|
-
browser: "phantomjs",
|
|
41
|
-
phantomjsOptions: `--cookies-file=${cookiesFile}`
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
...defaultOptions,
|
|
45
|
-
...newOptions
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return function () {
|
|
50
|
-
it ("should work on first vanilla full invocation, no checks", function (done) {
|
|
51
|
-
const options = createOptions({});
|
|
52
|
-
|
|
53
|
-
rimraf(outputBase);
|
|
54
|
-
|
|
55
|
-
ss.run(optHelp.decorate(options))
|
|
56
|
-
.then(() => {
|
|
57
|
-
cleanup(done);
|
|
58
|
-
}).catch(e => {
|
|
59
|
-
checkActualFiles(e.notCompleted)
|
|
60
|
-
.then(() => {
|
|
61
|
-
cleanup(done, e || unexpectedError);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it("should work with one string option", function (done) {
|
|
67
|
-
const options = createOptions({});
|
|
68
|
-
|
|
69
|
-
rimraf(outputBase);
|
|
70
|
-
|
|
71
|
-
ss.run(optHelp.decorate(options), (err, completed) => {
|
|
72
|
-
if (err) {
|
|
73
|
-
console.log(`@@@ error = ${err}, completed=${completed.join(',')}`);
|
|
74
|
-
}
|
|
75
|
-
})
|
|
76
|
-
.then(() => {
|
|
77
|
-
let assertionError;
|
|
78
|
-
try {
|
|
79
|
-
fs.accessSync(cookiesFile);
|
|
80
|
-
} catch (e) {
|
|
81
|
-
assertionError = e;
|
|
82
|
-
}
|
|
83
|
-
cleanup(done, assertionError);
|
|
84
|
-
})
|
|
85
|
-
.catch(e => {
|
|
86
|
-
checkActualFiles(e.notCompleted)
|
|
87
|
-
.then(function () {
|
|
88
|
-
cleanup(done, e || unexpectedError);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it("should work with multiple options, test one", function (done) {
|
|
94
|
-
const options = createOptions({
|
|
95
|
-
selector: "#inline-image",
|
|
96
|
-
phantomjsOptions: [
|
|
97
|
-
`--cookies-file=${cookiesFile}`,
|
|
98
|
-
"--load-images=true"
|
|
99
|
-
]
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
rimraf(outputBase);
|
|
103
|
-
|
|
104
|
-
ss.run(optHelp.decorate(options), (err, completed) => {
|
|
105
|
-
if (err) {
|
|
106
|
-
console.log(`@@@ error = ${err}, completed=${completed.join(',')}`);
|
|
107
|
-
}
|
|
108
|
-
})
|
|
109
|
-
.then(() => {
|
|
110
|
-
let assertionError;
|
|
111
|
-
try {
|
|
112
|
-
fs.accessSync(cookiesFile);
|
|
113
|
-
} catch (e) {
|
|
114
|
-
assertionError = e;
|
|
115
|
-
}
|
|
116
|
-
cleanup(done, assertionError);
|
|
117
|
-
})
|
|
118
|
-
.catch(e => {
|
|
119
|
-
checkActualFiles(e.notCompleted)
|
|
120
|
-
.then(() => {
|
|
121
|
-
cleanup(done, e || unexpectedError);
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it("should work with multiple options, test two", function (done) {
|
|
127
|
-
const options = createOptions({
|
|
128
|
-
selector: "#inline-image",
|
|
129
|
-
timeout: 5000, // this should fail, so don't wait too long.
|
|
130
|
-
phantomjsOptions: [
|
|
131
|
-
`--cookies-file=${cookiesFile}`,
|
|
132
|
-
"--load-images=false"
|
|
133
|
-
]
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
rimraf(outputBase);
|
|
137
|
-
|
|
138
|
-
ss.run(optHelp.decorate(options))
|
|
139
|
-
.then(unexpectedSuccess.bind(null, done))
|
|
140
|
-
.catch(err => {
|
|
141
|
-
let assertionError;
|
|
142
|
-
try {
|
|
143
|
-
resHelp.mustBeError(err);
|
|
144
|
-
} catch (e) {
|
|
145
|
-
assertionError = e;
|
|
146
|
-
}
|
|
147
|
-
cleanup(done, assertionError);
|
|
148
|
-
});
|
|
149
|
-
});
|
|
150
|
-
// most of these tests use no options, so not testing that again here
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
module.exports = {
|
|
155
|
-
testSuite: phantomjsOptionsTests
|
|
156
|
-
};
|