postdoc screenshot
Takes screenshots of pages in Chrome, to see a change rather than read it: at several window widths, in the light and the dark colour scheme, of the whole page or of one element. It waits until each page has finished rendering, as the page checks do.
Without --url, it builds the site and serves the build, like postdoc test. With
it, it uses a site that's already running, such as the dev server, which is quicker
and shows drafts.
Options:
--width <widths>- the window widths, in CSS pixels, separated by commas. Defaults to1280.--height <height>- the window height. Defaults to800.--theme <themes>-light,darkorlight,dark. Defaults tolight. Dark mode is switched on as the page checks do, with thenightwatch.pageChecks.a11y.darkModesettings.--selector <selector>- a CSS selector: only the first element it matches.--full-page- the whole page, not only the window.--url <address>- the address of a running site, such ashttp://localhost:5173.--out-dir <dir>- without--url, builds into this directory instead of the configuredoutputPath, which is then left as it is.--output <dir>- where to write the PNG files. Defaults toscreenshots.--wait <ms>- how long to wait after a page is ready, for maps, fonts and animations. Defaults to300.
It prints the path of each file it writes, and exits with 1 when a page doesn't load,
such as one that isn't there. It needs Chrome, and selenium-webdriver, which comes
with Nightwatch.
Example
sh
npx postdoc screenshot /guide/index.html --width 1280,390 --theme light,dark