Skip to content

Commit

Permalink
Merge pull request #749 from wheresrhys/rhys/body-call-inspection
Browse files Browse the repository at this point in the history
fix: make a more sensible decision about matching body
  • Loading branch information
wheresrhys authored Jul 24, 2024
2 parents d1ce46c + 0ef50d6 commit c11d7aa
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/core/src/Matchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,16 @@ const getExpressParamsMatcher = ({ params: expectedParams, url }) => {
const getBodyMatcher = (route) => {
const { body: expectedBody } = route;

if (!expectedBody) {
return;
}

return ({ options: { body, method = 'get' } }) => {
if (method.toLowerCase() === 'get') {
// GET requests don’t send a body so the body matcher should be ignored for them
return true;
if (['get', 'head', 'delete'].includes(method.toLowerCase())) {
// GET requests don’t send a body so even if it exists in the options
// we treat as no body because it would never actually make it to the server
// in the application code
return false;
}

let sentBody;
Expand Down

0 comments on commit c11d7aa

Please sign in to comment.