0.3.0 • Published 6 years ago

styleshots v0.3.0

Weekly downloads
1
License
ISC
Repository
-
Last release
6 years ago

Styleshots

styleshots generates automatic jest snapshots for your styles

Getting Started

Create a new test file and invoke styleshots with your configuration options.

// styleshots.spec.js
import styleshots from "styleshots";

styleshots({
  url: "http://fancy-app.com",
  projectName: "Fancy App",
  selectors: [
    ".fancy-className-1",
    "#fancy-element-id",
    {
      selector: ".fancy-hoverable-element",
      hover: true
    }
  ]
});

Then, run your jest test suites as normal. For example:

yarn jest styleshots.spec.js

Configuration

url

Url from which to extact style information

selectors

Array of selectors to snapshot. Each element in the array can be a string, or a configuration object with the following properties:

propertytypedescriptiondefault
selectorstringDOM selector to snapshotn/a (required)
hoverbooleanextracts styles for selector while element is hovered.false
activebooleanextracts styles for selector while element is active.false
focusbooleanextracts styles for selector while element is focused.false
allMatchesbooleangenerates snapshot for all elements found that match selector.false
projectNamestringset the name of the project under test. Used for generating snapshot titleurl

viewport

sets viewport of page. Defaults to width: 1280, height: 768 }.

debug

Log console output from url page

0.3.0

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago