node-jest/jest-snapshot-serializer-raw
Lu zhiping c0606860b8 Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
..
src Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
tests Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
.editorconfig Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
.gitattributes Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
.gitignore Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
.npmignore Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
.travis.yml Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
CHANGELOG.md Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
LICENSE Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
README.md Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
ThirdPartyNoticeText.txt Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
always.d.ts Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
always.js Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
jest.config.js Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
package-lock.json Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
package.json Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
prettier.config.js Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
renovate.json Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
tsconfig.build.json Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
tsconfig.json Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00
tslint.json Import Upstream version 27.5.1~ds+~cs69.51.22 2022-07-16 13:02:45 +08:00

README.md

jest-snapshot-serializer-raw

npm build coverage

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

# using npm
npm install --save-dev jest-snapshot-serializer-raw

# using yarn
yarn add --dev jest-snapshot-serializer-raw

Usage

Apply to specified snapshots

{
  "snapshotSerializers": ["jest-snapshot-serializer-raw"]
}
// test.js

const { wrap } = require('jest-snapshot-serializer-raw');
const example = `paragraph "one"\n\n'paragraph' \\two\\`;

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

test('after', () => {
  expect(wrap(example)).toMatchSnapshot();
});
// test.js.snap

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

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

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

'paragraph' \\two\\
`;

Apply to all snapshots

{
  "snapshotSerializers": ["jest-snapshot-serializer-raw/always"]
}
// test.js

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

test('after', () => {
  expect(example).toMatchSnapshot();
});
// test.js.snap

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

'paragraph' \\two\\
`;

Development

# lint
yarn run lint

# build
yarn run build

# test
yarn run test

License

MIT © Ika