Ignoring Differences
Ignoring differences programmatically
Last updated
Ignoring differences programmatically
Last updated
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:
This function allows users to specify conditions under which a particular mock difference should be ignored.
Input parameters:
mockDiff: An object describing the difference between the recorded mock and the replayed one.
currentMock: The original mock object recorded during testing.
requestObj: The request for which this mock difference was captured.
Check out detailed Type Reference for Input Parameters here.
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:
This function allows users to specify conditions under which a particular response difference should be ignored.
Input parameters:
responseDiff: An object describing the difference between the expected response and the actual one.
requestObj: The request for which this response difference was captured.
Check out detailed Type Reference for Input Parameters here.
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.