Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tribou/jest-serializer-path
Remove absolute paths from your Jest snapshots
https://github.com/tribou/jest-serializer-path
absolute-paths jest jest-serializer jest-serializer-path jest-snapshots snapshot snapshot-testing testing
Last synced: 2 months ago
JSON representation
Remove absolute paths from your Jest snapshots
- Host: GitHub
- URL: https://github.com/tribou/jest-serializer-path
- Owner: tribou
- License: apache-2.0
- Created: 2017-05-05T20:24:05.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T09:17:11.000Z (about 2 years ago)
- Last Synced: 2024-11-01T20:29:21.305Z (3 months ago)
- Topics: absolute-paths, jest, jest-serializer, jest-serializer-path, jest-snapshots, snapshot, snapshot-testing, testing
- Language: JavaScript
- Size: 49.2 MB
- Stars: 19
- Watchers: 3
- Forks: 8
- Open Issues: 22
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# jest-serializer-path
[![npm version](https://badge.fury.io/js/jest-serializer-path.svg)](https://badge.fury.io/js/jest-serializer-path)
[![Linux Build Status](https://img.shields.io/circleci/project/github/tribou/jest-serializer-path/master.svg?label=linux%20build)](https://circleci.com/gh/tribou/jest-serializer-path/tree/master)
[![Windows Build Status](https://img.shields.io/appveyor/ci/tribou/jest-serializer-path/master.svg?label=windows%20build)](https://ci.appveyor.com/project/tribou/jest-serializer-path/branch/master)
[![Coverage Status](https://coveralls.io/repos/github/tribou/jest-serializer-path/badge.svg?branch=master)](https://coveralls.io/github/tribou/jest-serializer-path?branch=master)
[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active)
[![bitHound Code](https://www.bithound.io/github/tribou/jest-serializer-path/badges/code.svg)](https://www.bithound.io/github/tribou/jest-serializer-path)Remove absolute paths and normalize paths across all platforms in your Jest snapshots.
#### Quick Start
```bash
npm install --save-dev jest-serializer-path
```Add this to your `package.json` Jest config:
```
"jest": {
"snapshotSerializers": [
"jest-serializer-path"
]
}
```Or include only in individual tests:
```js
const serializer = require("jest-serializer-path");expect.addSnapshotSerializer(serializer);
```All absolute paths will now be converted and saved in snapshots like so:
`/path/to/my-proj/lib` => `/lib`
`/path/to/os-temp/nested/temp` => `/nested/temp`
`/path/to/user-home/nested/home` => `/nested/home`
#### Caveats
* All single backslashes (`\`) will be replaced by a forward slash (`/`).
* Any string that looks like a Windows drive letter (`C:\`) will be replaced by a forward slash (`/`).#### Build
This project bundles the yarn executable and the npm/yarn dependencies offline
in the `.npm-packages-offline-cache` directory for faster dependency installs
and better dev/prod parity across including preventing failure if yarn/npm is
offline.```sh
# Install
npm run yarn# Run tests
npm run test
```