A plugin for jest that supports graphviz integration.
The plugin can then be installed using npm:
yarn add -D jest-graphviz
npm install --save-dev jest-graphviz
Import jest-graphviz
with the script specified in setupFilesAfterEnv
.
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
verbose: true,
collectCoverage: true,
setupFilesAfterEnv: [
// Add this.
'<rootDir>/config/jest/setup-jest.ts',
],
};
import 'jest-graphviz';
This extension requires Graphviz. If you don't have it installed, install it herehere.
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();
});
});
describe('toBeValidDotAndMatchSnapshot test', () => {
test('matcher works', () => {
const dot = 'digraph g { a -> b; }';
expect(dot).toBeValidDotAndMatchSnapshot();
});
});
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.
Graphviz-dot Test and Integration
- ts-graphviz
- Graphviz library for TypeScript.
- @ts-graphviz/react
- Graphviz-dot Renderer for React.
- setup-graphviz
- GitHub Action to set up Graphviz cross-platform(Linux, macOS, Windows).
This software is released under the MIT License, see LICENSE.