Skip to content

Commit

Permalink
Block Test Fixtures: Add additional error message for serialized test…
Browse files Browse the repository at this point in the history
… fixtures that reserialize identically (#39039)

* Block Test Fixtures: Add additional error message for serialized test fixtures that do not match, but that reserialize identically

* Update error message
  • Loading branch information
andrewserong committed Feb 25, 2022
1 parent 6977aa4 commit 4bfe584
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions test/integration/full-content/full-content.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,26 @@ describe( 'full post content fixture', () => {
try {
expect( serializedActual ).toEqual( serializedExpected );
} catch ( err ) {
throw new Error(
format(
"File '%s' does not match expected value:\n\n%s",
serializedHTMLFileName,
err.message
)
);
if (
serialize( blocksActual ) ===
serialize( parse( serializedExpected ) )
) {
throw new Error(
format(
"File '%s' does not match expected value (however, the block re-serializes identically so you may need to run 'npm run fixtures:regenerate'):\n\n%s",
serializedHTMLFileName,
err.message
)
);
} else {
throw new Error(
format(
"File '%s' does not match expected value:\n\n%s",
serializedHTMLFileName,
err.message
)
);
}
}
} );
} );
Expand Down

0 comments on commit 4bfe584

Please sign in to comment.