# jest-graphviz

> A plugin for jest that supports graphviz integration.

Latest version **0.5.0** (published 2021-09-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install jest-graphviz
pnpm add jest-graphviz
yarn add jest-graphviz
bun add jest-graphviz
```

## Health

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

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.0 |
| Published | 2021-09-23 |
| First published | 2019-11-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 12.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | kamiazya |
| Maintainers | kamiazya |
| Keywords | jest, graphviz, dot |

## Links

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

## Dependencies (2)

- [tslib](https://npm.io/package/tslib.md) ^2.3.1
- [jest-snapshot](https://npm.io/package/jest-snapshot.md) ^27.2.1

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 0.5.0 (latest) — 2021-09-23
- 0.4.0 — 2021-01-10
- 0.3.1 — 2020-04-25
- 0.3.0 — 2020-04-24
- 0.2.0 — 2020-01-13
- 0.1.1 — 2019-12-15
- 0.1.0 — 2019-12-14
- 0.0.2 — 2019-11-10
- 0.0.1 — 2019-11-10

## README

[![GitHub Action](https://github.com/kamiazya/jest-graphviz/workflows/NodeCI/badge.svg)](https://github.com/kamiazya/jest-graphviz/actions?workflow=NodeCI) [![npm version](https://badge.fury.io/js/jest-graphviz.svg)](https://badge.fury.io/js/jest-graphviz) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier) [![Test Coverage](https://api.codeclimate.com/v1/badges/b5856ac3f3ced5b64a05/test_coverage)](https://codeclimate.com/github/kamiazya/jest-graphviz/test_coverage)

# jest-graphviz

A plugin for [jest](https://jestjs.io/) that supports [graphviz](https://graphviz.gitlab.io/) integration.

## Installation

The plugin can then be installed using [npm](https://www.npmjs.com/):

[![NPM](https://nodei.co/npm/jest-graphviz.png)](https://nodei.co/npm/jest-graphviz/)

### yarn

```bash
yarn add -D jest-graphviz
```

### npm

```bash
npm install --save-dev jest-graphviz
```

## Configuration

Import `jest-graphviz` with the script specified in [`setupFilesAfterEnv`](https://jestjs.io/docs/en/configuration#setupfilesafterenv-array).

### Example

#### `jest.config.js`

```javascript
module.exports = {
  preset: 'ts-jest',
  testEnvironment: 'node',
  verbose: true,
  collectCoverage: true,
  setupFilesAfterEnv: [
    // Add this.
    '<rootDir>/config/jest/setup-jest.ts',
  ],
};
```

#### `config/jest/setup-jest.ts`

```typescript
import 'jest-graphviz';
```

## Requirement

This extension requires Graphviz.
If you don't have it installed, install it here[here](https://graphviz.gitlab.io/download/).

## Usage

### `toBeValidDot`

```typescript
describe('toBeValidDot test', () => {
  it('matcher works', () => {
    const dot = 'digraph g { a -> b; }';
    expect(dot).toBeValidDot();
  });

  it('invalid dot', () => {
    const dot = 'invalid';
    expect(dot).not.toBeValidDot();
  });
});
```

### `toBeValidDotAndMatchSnapshot`

```typescript
describe('toBeValidDotAndMatchSnapshot test', () => {
  test('matcher works', () => {
    const dot = 'digraph g { a -> b; }';
    expect(dot).toBeValidDotAndMatchSnapshot();
  });
});
```

### `toMatchDotJsonSnapshot`

```typescript
describe('toMatchDotJsonSnapshot test', () => {
  test('matcher works', () => {
    const dot = 'digraph g { a -> b; }';
    expect(dot).toMatchDotJsonSnapshot();
  });
});
```

> It depends on the JSON output format added in Graphviz 2.40.0.

## See Also

Graphviz-dot Test and Integration

- [ts-graphviz](https://github.com/ts-graphviz/ts-graphviz)
  - Graphviz library for TypeScript.
- [@ts-graphviz/react](https://github.com/ts-graphviz/react)
  - Graphviz-dot Renderer for React.
- [setup-graphviz](https://github.com/ts-graphviz/setup-graphviz)
  - GitHub Action to set up Graphviz cross-platform(Linux, macOS, Windows).

## License

This software is released under the MIT License, see LICENSE.

## Author

[kamiazya(Yuki Yamazaki)](https://github.com/kamiazya)

[![ko-fi](https://www.ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/W7W5VDNO)

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