Hi,
I’m trying to practise TDD with Elm and encapsulate implementation as much as possible. I find it hard to manage both properly and I looking for some advice on how to handle this properly.
Where I struggle in particular is creating an expected result for my test. I cannot construct them in my test because that would mean I have to expose the implementation. I currently fix this by creating builder helpers in my module, but I don’t like that for the following reasons:
- I’m not sure that the builder method constructs my expected result properly, because there’s no way of testing it
- The implementation is leaking out of the module through the builder methods. It’s now also possible to create the internals through a way that wouldn’t be there if I didn’t use tests.
I believe in both TDD and encapsulation but currently I feel I cannot use them properly in Elm. Any advise in how I could make the best of both?
PS. I’m working on an app, not on a package. This is perhaps relevant for the advice.