Skip to content
This repository has been archived by the owner on Aug 14, 2021. It is now read-only.
/ puppetbox Public archive

Capture screenshots of HTML strings using Chrome's headless mode.

Notifications You must be signed in to change notification settings

TimDaub/puppetbox

Repository files navigation

puppetbox

Node.js CI

Capture screenshots of HTML using Chrome's headless mode.

Requirements

Why puppetbox?

  • Its code base is tiny and maintainable.
  • It's framework-agnostic. All that is needed to get started is a HTML string.

Installation

$ npm i -D puppetbox

Usage

puppetbox allows you to capture screenshots using headless Chrome by entering a HTML string. For visual regression testing, a screenshot could later be compared using looks-same.

import { capture, htmlEnvelope } from "puppetbox";
import { writeFileSync } from "fs";

(async () => {
  const input = htmlEnvelope("<p style="font-family: Arial;">hello world</p>");

  const screenshot = await capture(input, {
    height: 100,
    width: 100
  });
  writeFileSync(`example.png`, screenshot)
})();

screenshot of "example.png" below:

example.png

Notes

Changelog

0.1.0

Stop embedding fragments in HTML doc.

  • Stop exporting capture as default
  • Export htmlEnvelope function
  • Add tests for capture and htmlEnvelope functions
  • Add Note about how headless Chrome renders fragments differently from documents

0.0.1

  • Release initial version

License

See License.

About

Capture screenshots of HTML strings using Chrome's headless mode.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published