elm-program-test icon indicating copy to clipboard operation
elm-program-test copied to clipboard

Add a way to get the model from a `ProgramTest`

Open JasterV opened this issue 3 years ago • 2 comments

I'm storing some data inside the model that I would like to use on the tests to compute some values.

For example, I'm storing the currentDate inside the model, and later on I need the currentdate to mock an HTTP response.

So I would like to be able to do something like:

start
    |> ProgramTest.withModel
         (\model -> 
               ProgramTest.simulateHttpOk "POST" mockUrl (responseSuccess model.currentDate)
         )
       |> ProgramTest.clickButton "button"
       |> ProgramTest.expectViewHasNot [ Selector.id "test-id" ]

The signature of the function could be something like:

withModel : (model -> ProgramTest model msg effect -> ProgramTest model msg effect) -> ProgramTest model msg effect -> ProgramTest model msg effect

What do you think? If you agree I could even open a PR myself :)

JasterV avatar Oct 27 '22 14:10 JasterV

I feel this could be kinda related to #127 even though it is not exactly the same

JasterV avatar Oct 27 '22 14:10 JasterV

@avh4 is this library being maintained? Otherwise, are there any alternatives?

JasterV avatar Nov 08 '22 09:11 JasterV