Closed elopez89 closed 4 years ago
While reviewing the diff between requests the following aws request headers seem to always get updated x-amz-date, date and x-amzn-requestid
Try adding the following to your polly config:
matchRequestsBy: {
headers: { exclude: ['x-amz-date', 'date', 'x-amzn-requestid', 'authenticationToken'] }
}
@offirgolan This worked! But unsure why? I was expecting those headers to be removed from the .har file but they are still there. What does this option do? There isn't much information in the documentation other than:
Type: Boolean | Function | Object Default: true
The request headers.
The matchRequestsBy
config determines how Polly generates the request's unique id so that it can be matched when replayed. The above config tells Polly to ignore those headers when generating the GUID.
Description
Pollyjs doesn't seem to replay requests made with the node aws-sdk whenever I run my jest test, the aws request entry inside the recording still seems to be modified. While reviewing the diff between requests the following aws request headers seem to always get updated
x-amz-date,
date
andx-amzn-requestid
.We use AWS Secrets Manager to get API keys, database passwords, and so on. I am sure that it is the aws request because the requests were saved and then replayed successfully when I hardcoded the retrieved secrets and bypassed the request to aws.
Shareable Source
JEST Test
someAPIRequest
Jest test setup file
This will run prior to every test.
Error Message & Stack Trace
Whenever I run pollyjs with the option 'recordIfMissing' set to false I see the error 'node-http-adapter' as follows:
=[Polly] [adapter:node-http] Recording for the following request is not found and `recordIfMissing` is `false`.
That makes sense because the file is being changed every time so Pollyjs tries to look for it but it doesn't fit the one that was saved previously.
Config
Dependencies
Environment