c0606860b8 | ||
---|---|---|
.. | ||
src | ||
tests | ||
.editorconfig | ||
.gitattributes | ||
.gitignore | ||
.npmignore | ||
.travis.yml | ||
CHANGELOG.md | ||
LICENSE | ||
README.md | ||
ThirdPartyNoticeText.txt | ||
always.d.ts | ||
always.js | ||
jest.config.js | ||
package-lock.json | ||
package.json | ||
prettier.config.js | ||
renovate.json | ||
tsconfig.build.json | ||
tsconfig.json | ||
tslint.json |
README.md
jest-snapshot-serializer-raw
jest snapshot serializer for reducing escapes in the snapshot file
(This package is modified from prettier/prettier:tests_config/raw-serializer.js@9ec1da1a
)
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