Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const {
filename: jsonFixtureFileName,
file: jsonFixtureContent,
} = getBlockFixtureJSON( basename );
let blocksExpectedString;
if ( jsonFixtureContent ) {
blocksExpectedString = jsonFixtureContent;
} else if ( process.env.GENERATE_MISSING_FIXTURES ) {
blocksExpectedString = JSON.stringify(
blocksActualNormalized,
null,
4
) + '\n';
writeBlockFixtureJSON( basename, blocksExpectedString );
} else {
throw new Error(
`Missing fixture file: ${ jsonFixtureFileName }`
);
}
const blocksExpected = JSON.parse( blocksExpectedString );
try {
expect(
blocksActualNormalized
).toEqual( blocksExpected );
} catch ( err ) {
throw new Error( format(
"File '%s' does not match expected value:\n\n%s",
jsonFixtureFileName,
err.message