How to use the jest-snapshot.toMatchSnapshot.call function in jest-snapshot

To help you get started, we’ve selected a few jest-snapshot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tivac / modular-css / packages / test-utils / expect / toMatchRollupCodeSnapshot.js View on Github external
output.forEach(({ isAsset, name, code }) => {
            if(isAsset) {
                return;
            }

            chunks.set(name, `\n${code}`);
        });

        const out = Object.create(null);
        
        // Ensure out object is in a consistent order
        [ ...chunks.keys() ].sort().forEach((key) => {
            out[key] = chunks.get(key);
        });

        return toMatchSnapshot.call(
            this,
            out,
        );
    },
});
github tivac / modular-css / packages / test-utils / expect / toMatchRollupAssetSnapshot.js View on Github external
output.forEach(({ isAsset, fileName, source }) => {
            if(!isAsset) {
                return;
            }
            
            assets.set(fileName, `\n${source}`);
        });
        
        const out = Object.create(null);

        // Ensure out object is in a consistent order
        [ ...assets.keys() ].sort().forEach((key) => {
            out[key] = assets.get(key);
        });

        return toMatchSnapshot.call(
            this,
            out,
        );
    },
});
github tivac / modular-css / packages / test-utils / expect / toMatchRollupSnapshot.js View on Github external
toMatchRollupSnapshot({ output }, name = "") {
        const things = new Map();
        
        output.forEach(({ code, isAsset, fileName, source }) => {
            // Leading newline to make diffs easier to read
            things.set(fileName, `\n${isAsset ? source : code}`);
        });
        
        const out = Object.create(null);

        // Ensure out object is in a consistent order
        [ ...things.keys() ].sort().forEach((key) => {
            out[key] = things.get(key);
        });
        
        return toMatchSnapshot.call(
            this,
            out,
            name,
        );
    },
});
github styled-components / jest-styled-components / src / matchers / toMatchStyledComponentsSnapshot.js View on Github external
function toMatchStyledComponentsSnapshot(received) {
  const result = toMatchSnapshot.call(this, received)
  let message

  if (!result.pass) {
    message = diff(result.expected, result.actual, {
      aAnnotation: 'Snapshot',
      bAnnotation: 'Received',
    })
    message = stripAnsi(message)
    message = colorize(message)
  }

  return { pass: result.pass, message }
}