Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

jest-snapshot-serializer-raw

ikatyang68.6kMIT2.0.0TypeScript support: included

jest snapshot serializer for reducing escapes in the snapshot file

jest, jest-snapshot-serializer

readme

jest-snapshot-serializer-raw

npm build

jest snapshot serializer for reducing escapes in the snapshot file

(This package is modified from prettier/prettier:tests_config/raw-serializer.js@9ec1da1a)

Changelog

Install

npm install jest-snapshot-serializer-raw

Note: This package is now pure ESM, you may want to install jest-snapshot-serializer-raw@1 if you'd like to use it in CJS environment

Usage

Apply to specified snapshots

In setup file or test file:

import serializerRaw from 'jest-snapshot-serializer-raw'
expect.addSnapshotSerializer(serializerRaw)

In test file:

import { wrap } from 'jest-snapshot-serializer-raw'
const example = `paragraph "one"\n\n'paragraph' \\two\\`

test('before', () => {
  expect(example).toMatchSnapshot()
})

test('after', () => {
  expect(wrap(example)).toMatchSnapshot()
})

In snapshot file:

exports[`before 1`] = `
"paragraph \\"one\\"

'paragraph' \\\\two\\\\"
`

exports[`after 1`] = `
paragraph "one"

'paragraph' \\two\\
`

Apply to all snapshots

In setup file or test file:

import serializerRaw from 'jest-snapshot-serializer-raw/always'
expect.addSnapshotSerializer(serializerRaw)

In test file:

const example = `paragraph "one"\n\n'paragraph' \\two\\`

test('after', () => {
  expect(example).toMatchSnapshot()
})

In snapshot file:

exports[`after 1`] = `
paragraph "one"

'paragraph' \\two\\
`

Development

# lint
pnpm run lint

# build
pnpm run build

# test
pnpm run test

License

MIT © Ika

changelog

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

2.0.0 (2023-07-15)

Build System

BREAKING CHANGES

  • this package is now pure ESM

1.2.0 (2021-04-25)

Features

  • add an always entrypoint for the usage without wrap function (#65) (351f290)

1.1.0 (2018-07-10)

Features

1.0.0 (2018-06-20)

Features