Remove extra line breaks from Jest Test Snapshot?

Viewed 957

In my vanilla html Jest snapshot, there are three line breaks after most elements. For larger snapshots, it would be more readable if the serialization was compact with no extra line breaks.

I've tried adding a custom serializer as recommended by pretty formatter adding min: true to the config but it doesn't not remove the extra new line characters. I have also tried returning a string from the serialize method removing all new line break characters.

// custom-snapshot-serializer.js
const prettyFormat = require('pretty-format');

module.exports = {
    test: (val) => typeof val === 'string',

    serialize: (val) => prettyFormat(val),

    config: {min: true, spacingInner: '', spacingOuter: ''}
};

Here is what the snapshot currently looks like with extra line breaks:

snapshot

0 Answers
Related