Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it( basename, () => {
const {
filename: htmlFixtureFileName,
file: htmlFixtureContent,
} = getBlockFixtureHTML( basename );
if ( htmlFixtureContent === null ) {
throw new Error(
`Missing fixture file: ${ htmlFixtureFileName }`
);
}
const {
filename: parsedJSONFixtureFileName,
file: parsedJSONFixtureContent,
} = getBlockFixtureParsedJSON( basename );
const parserOutputActual = grammarParse( htmlFixtureContent );
let parserOutputExpectedString;
if ( parsedJSONFixtureContent ) {
parserOutputExpectedString = parsedJSONFixtureContent;
} else if ( process.env.GENERATE_MISSING_FIXTURES ) {
parserOutputExpectedString = JSON.stringify(
parserOutputActual,
null,
4
) + '\n';
writeBlockFixtureParsedJSON( basename, parserOutputExpectedString );
} else {
throw new Error(
`Missing fixture file: ${ parsedJSONFixtureFileName }`
);
}