Noteworthy Placebo Mongers

    jest-snapshot-serializer-raw
    TypeScript icon, indicating that this package has built-in type declarations

    1.2.0 • Public • Published

    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

    Install

    npm i jest-snapshot-serializer-raw

    DownloadsWeekly Downloads

    27,273

    Version

    1.2.0

    License

    MIT

    Unpacked Size

    7.98 kB

    Total Files

    11

    Last publish

    Collaborators

    • ikatyang