Open cjmaynar opened 4 years ago
At nodejs/nestjs I had to add asymmetricMatch to de FormData mock
const formData = new FormData() as any;
formData.append('image', mockUploadFile);
formData.asymmetricMatch = (actual) => {
// Validate and return true or false, 'this' is the expected
};
mock.onPut(url, formData).replyOnce(200);
because at utils.js at line 86 where the validation of the body happen
function isObjectMatching(actual, expected) {
if (expected === undefined) return true;
if (typeof expected.asymmetricMatch === "function") {
return expected.asymmetricMatch(actual);
}
return isEqual(actual, expected);
}
Release of v1.18.0 causes tests using
FormData
with post requests to fail. It seems as of 1.18.0onPost
with an expected data ofFormData
returns a 404 instead of whatever the reply is supposed to be.Below is a sample component and test that passes in v1.17.0 and fails in v1.18.0
After upgrading to v1.18.0 to make things pass the component must change to no longer send a FormData instance - to now be a regular JS object - and the test must change to expect that as well