# styleshots

> automated snapshot testing for your styles

Latest version **0.3.0** (published 2018-01-13) · ISC license · 0 weekly downloads

## Install

```sh
npm install styleshots
pnpm add styleshots
yarn add styleshots
bun add styleshots
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2018-01-13 |
| First published | 2017-12-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Andrew Hansen |
| Maintainers | arahansen |
| Keywords | styles, css, snapshot, testing, jest |

## Links

- npm: https://www.npmjs.com/package/styleshots
- npm.io page: https://npm.io/package/styleshots

## Dependencies (2)

- [jest](https://npm.io/package/jest.md) ^22.0.4
- [puppeteer](https://npm.io/package/puppeteer.md) ^0.13.0

## Alternatives

- [duck](https://npm.io/package/duck.md) — 4.2M weekly downloads
- [ava](https://npm.io/package/ava.md) — 560.2K weekly downloads
- [storybook-addon-module-mock](https://npm.io/package/storybook-addon-module-mock.md) — 71.7K weekly downloads
- [@ethereum-waffle/mock-contract](https://npm.io/package/@ethereum-waffle/mock-contract.md) — 40.0K weekly downloads
- [aws-elasticsearch-connector](https://npm.io/package/aws-elasticsearch-connector.md) — 37.4K weekly downloads

## Recent versions

- 0.3.0 (latest) — 2018-01-13
- 0.2.1 — 2018-01-12
- 0.2.0 — 2018-01-04
- 0.1.0 — 2017-12-29
- 0.0.1 — 2017-12-24

## README

# Styleshots

`styleshots` generates automatic jest snapshots for your styles

## Getting Started

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

```js
// 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:

| **property**  | **type** | **description**                                                            | **default**    |
| ------------- | -------- | -------------------------------------------------------------------------- | -------------- |
| `selector`    | string   | DOM selector to snapshot                                                   | n/a (required) |
| `hover`       | boolean  | extracts styles for `selector` while element is hovered.                   | false          |
| `active`      | boolean  | extracts styles for `selector` while element is active.                    | false          |
| `focus`       | boolean  | extracts styles for `selector` while element is focused.                   | false          |
| `allMatches`  | boolean  | generates snapshot for all elements found that match `selector`.           | false          |
| `projectName` | string   | set the name of the project under test. Used for generating snapshot title | `url`          |

### `viewport`

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

### `debug`

Log console output from `url` page

---
_Source: https://npm.io/package/styleshots · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
