Ignoring Differences
Ignoring differences programmatically
In some scenarios, you might want to ignore certain differences between expected mocks/responses and actual ones.
These differences may be due to env variables, timestamps, or other non-critical factors that don't represent true regressions.
HyperTest allows to provide custom filtering logic to ignore such differences through two filter functions:
filterFunctionToIgnoreMockDiffs:
This function allows users to specify conditions under which a particular mock difference should be ignored.
Input parameters:
Return value:
The function should return a boolean, false for ignoring and true for keeping the difference.
Consider a case where you're making an outbound call to a 3rd party service and some metadata is being sent along with it, getting this error for random metadata is undesirable.
You can ignore any differences originating from metadata field like shown in the given example:
filterFunctionToIgnoreResponseDiffs:
This function allows users to specify conditions under which a particular response difference should be ignored.
Input parameters:
Return value:
The function should return a boolean, false for ignoring and true for keeping the difference.
Consider a case where you're sending out some metrics about the order processing to the client, the processing time would definitely vary from an actual env vs a mocked environment, as this is not a real regression it should not be considered.
By customizing these functions, you can tailor the test results to focus on actual regressions while ignoring known, non-critical changes.
Last updated