Socket
Socket
Sign inDemoInstall

jest-snapshot-serializer-raw

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    jest-snapshot-serializer-raw

jest snapshot serializer for reducing escapes in the snapshot file


Version published
Weekly downloads
16K
increased by12.19%
Maintainers
1
Install size
8.04 kB
Created
Weekly downloads
 

Changelog

Source

2.0.0 (2023-07-15)

Build System

  • update infra (#82) (4d233c3)

BREAKING CHANGES

  • this package is now pure ESM

<a name="1.2.0"></a>

Readme

Source

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

Keywords

FAQs

Last updated on 15 Jul 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc