Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ts-graphviz/jest-graphviz
🃏 A plugin for jest that supports graphviz integration.
https://github.com/ts-graphviz/jest-graphviz
graphviz graphviz-dot jest jest-plugin testing testing-library typescript-library
Last synced: 16 days ago
JSON representation
🃏 A plugin for jest that supports graphviz integration.
- Host: GitHub
- URL: https://github.com/ts-graphviz/jest-graphviz
- Owner: ts-graphviz
- License: mit
- Created: 2019-11-10T08:47:53.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-18T02:37:57.000Z (12 months ago)
- Last Synced: 2024-10-29T20:21:26.691Z (2 months ago)
- Topics: graphviz, graphviz-dot, jest, jest-plugin, testing, testing-library, typescript-library
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/jest-graphviz
- Size: 544 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 27
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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.
'/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)