So, I have a long series of unit tests that are located in a dedicated file to reduce noise in the associated code. In order to get that unit test module to compile, I must import it into main
or one of its dependencies.
The only problem is that the compiler emits a warning saying it's an unused import. But since it's just a long series of expect
blocks, it's technically "empty," so there is nothing to "use."
I would like to silence that warning for this case. I could just export a dummy value and try to find a benign way to "use" it in main.roc
, but that's pretty hacky.
I'm not sure I'm doing this the Roc Way™, but I feel like this is likely a common pattern. Am I just doing this wrong?
I always put them in the same file, can you share your code?
Sure, here is the branch on github:
https://github.com/austindd/tsml/tree/ast-implementation
And here is the file:
https://github.com/austindd/tsml/blob/ast-implementation/TokenTest.roc
Pardon the mess. I'm porting over a parser that I implemented in ReasonML, but I'm still working out the kinks for the type definitions right now, so it's pure chaos while I figure that out.
I think the relevant context here is that the Token.roc
module will eventually have hundreds (maybe thousands?) of unit tests to cover as many potential edge cases as possible. It's not the end of the world to put it all in the same file, but it's not ideal.
I always put them in the same file
I was wrong :p I have used separate files for tests before:
https://github.com/roc-lang/basic-cli/blob/main/tests/env.roc
These are apps and I run roc test
over everything in the roc test
folder with a script.
But, to do the same thing in your case, you would have to turn your project into a Roc package.
I think putting them in the same file has the best trade-offs, a bit annoying but really simple.
Last updated: Aug 17 2025 at 12:14 UTC