avh4 / elm-program-test

Test Elm programs
https://elm-program-test.netlify.com/
MIT License
93 stars 27 forks source link

Improve documentation for simulateHttpResponseAdvanced #164

Open avh4 opened 2 years ago

avh4 commented 2 years ago

People don't understand what the Int parameter means.

My explanation answering a slack thread:

it’s the index of which request in the queue for that method/URL to handle, so if you have 4 to the same method/URL that are all still pending, then you can choose 1, 2, 3, or 4 as the one to resolve. Note that if you made multiple of those requests at the same moment (in the same batch of effects), then there might be little trial and error to figure out what order they got put into the queue in. Also note that you only need that if the simultaneous requests were made to the same URL and HTTP method. If they were all to different URLs and/or methods, then you can just use the normal simulateHttpResponse

Also, when a request is resolved, it's no longer in the queue, so if you had 4 and resolved one of them, then there would only be 3 immediately after.

Also, it's safe to use the normal simulateHttpResponse if you're unsure, since the error message will tell you if you need to use simulateHttpResponseAdvanced.

It would probably be good to explain an example of one or more scenarios.

The goals for the docs here should be: