Closed zelenij closed 1 year ago
Hi @zelenij, I am not exactly sure why your HttpClient tests are failing but it is probably because we changed how a piece of JSON is serialized/deserialized and your HttpClient doesn't know how to work with the new shape of data. The remoting clients are usually updated to handle server-side changes under the hood as the JSON is an implementation detail for Fable.Remoting.
What I am wondering about is why you are using raw HttpClient to write tests when you can use Fable.Remoting.DotnetClient
to talk to your backend from a dotnet client. If you use DotnetClient
I assume it will understand the shape of the data from the remoting server.
Well, this makes sense. I saw Fable.Remoting.DotnetClient
, but for the life of me I couldn't figure out how to use it. Do you have a simple example please?
OK, thanks! Seems to be working. Now I need to update all those tests :)
Glad to hear that it is working 😄 will go ahead and close the issue. Feel free to open another one if you have any questions
I have a Fable app that uses
Fable.Remoting
. Among other things, it contains a few tests, that assess the server side via HTTP. Basically inside the test I submit some JSON via the standardSystem.Net.Http.HttpClient
and then check the return JSON.This worked pretty well with .NET6 + Fable 3. I didn't update any dependencies for close to a year. Now I have just upgraded everything to the latest Fable 4,
Fable.Remoting
, .NET7, Giraffe etc. After some tweaking everything seems to be working fine, including client/server communication from the browser. BUT theHttpClient
tests all fail. It seems that something happens to the incoming JSON and it is all treated as having fields set to null.Now, I doubt it is necessarily
Fable.Remoting
problem. Probably I'm doing something incorrectly. But I don't have a working theory at the moment. I added a print statement in my test code which serialises the objects to be sent withSystem.Text.Json.JsonSerializer.Serialize
, which is whatHttpClient
seems to do. And the result looks indistinguishable from what I can see in the browser.Any thoughts on how to address this?