Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marvinhagemeister/chai-snapshot-tests
Jest-like snapshot testing for chai
https://github.com/marvinhagemeister/chai-snapshot-tests
chai chaijs jest mocha snapshot snapshot-testing
Last synced: 9 days ago
JSON representation
Jest-like snapshot testing for chai
- Host: GitHub
- URL: https://github.com/marvinhagemeister/chai-snapshot-tests
- Owner: marvinhagemeister
- License: mit
- Created: 2017-06-12T15:42:29.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-06-13T08:09:59.000Z (over 7 years ago)
- Last Synced: 2025-01-05T18:45:11.671Z (16 days ago)
- Topics: chai, chaijs, jest, mocha, snapshot, snapshot-testing
- Language: TypeScript
- Size: 22.5 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Chai Snapshot Tests
Adds support for [Jest-like snapshot testing](https://facebook.github.io/jest/docs/snapshot-testing.html)
to chai. It works by creating a `__snapshots__` directory alongside your tests,
which contains the snapshot files in `json` format.## Installation
```bash
# npm
npm install --save-dev chai-snapshot-tests# yarn
yarn add --dev chai-snapshot-tests
```## Usage
```js
const chai = require("chai");
const snapshots = require("chai-snapshot-tests");// snapshots will be created relative to the current file
// `foo/bar/mytest.js` -> `foo/bar/__snapshots__/mytest.js.json`
chai.use(snapshots(__filename));const { assert, expect } = chai;
// Example with strings, but works with anything!
// With assert style assertions
assert.snapshot("snapName", "This is the expected text");
// or with expect style assertions
expect("This is the expected text").toMatchSnapshot("snapName");// Pass `true` to update the snapshot `snapName` with a new value
expect("Another text").toMatchSnapshot("snapName", true);
```## License
MIT, see [License.md](LICENSE.md)