@fundamend/plugin-vitest-easy-snapshot
v0.0.2
Published
_plugin-vitest-easy-snapshot_ is a helper module for [vitest] used by the [fundamend.dev] ecosystem. It allows you to easily take file and image snapshots of any number of HTML elements on a page.
Downloads
5
Readme
@fundamend/plugin-vitest-easy-snapshot
plugin-vitest-easy-snapshot is a helper module for vitest used by the fundamend.dev ecosystem. It allows you to easily take file and image snapshots of any number of HTML elements on a page.
Installation
Use your favorite Node.js package manager, for example npm, like so:
npm install --save-dev @fundamend/plugin-vitest-easy-snapshot
... or yarn, like so:
yarn add --dev @fundamend/plugin-vitest-easy-snapshot
Usage
In your test.js
, import plugin-vitest-easy-snapshot and capture snapshots of any number of elements, like so:
import run from '@fundamend/plugin-vitest-easy-snapshot';
run({
url: 'http://localhost:1234',
elements: [
'data-test-id-1',
'data-test-id-2',
'data-test-id-3'
]
});
url
is the URL of the server, where the page you want to test can be reached.elements
is an array of HTML elements for which you want to generate file and image snapshots.