Open janosgy opened 2 years ago
Just as a comment: This has two pieces that break. One is the signature comparison of the request and the second is the actual body comparison.
The first breaks because we see for the actual request this signature
"POST /test { data: {myObj: Instance of 'TestObj'}, query parameters: {}, headers: {content-type: application/json, content-length: 25} }"
but it should be "POST /test { data: {myObj: {nested: true}}, query parameters: {}, headers: {} }"
.
The latter breaks because we have now a TestObj
instance in the comparison and that is supposed to not match.
Description
According to my observation, the
data
field ondioAdapter.onPost
is compared before it's encoded to json.I use json_annotation, where some fields are configured not to be present if their value is
null
when encoded to json, but the tests are failing with "Could not find mocked route matching request for POST" and the data is shown with the null fields included + also instances have their types in the error message.when I experimented with
print(json.encode(originalData) == json.encode(expectationFromTest));
the result istrue
Steps to reproduce
Produces this error:
Expected behavior
Data from
dio.post
is encoded before comparing todioAdapter
'sonPost
dataSystem details
[✓] Flutter (Channel stable, 3.0.5, on macOS 12.3.1 21E258 darwin-arm, locale en-HU) [✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1) [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1) [✓] Chrome - develop for the web [!] Android Studio (not installed) [✓] IntelliJ IDEA Ultimate Edition (version 2021.3.3) [✓] VS Code (version 1.64.1) [✓] Connected device (2 available) [✓] HTTP Host Availability
dio: ^4.0.4 http_mock_adapter: ^0.3.2