https://mobile.twitter.com/antfu7/status/1468233216939245579 but at the function level :smiley:
Just like how Vite works in the browser, Vitest also knows the graph of your modules, which makes it able to do smart detection and only rerun the related tests. Feels almost like HMR but for tests :heart_eyes: https://twitter.com/antfu7/status/1468233216939245579/photo/1
- Anthony Fu (@antfu7)It would also be nice to show what code the editor considers to be related to the test and what test is related to some piece of code.
I was just about to ask everyone what testing libraries we'd like to see a Roc equivalent of, and here (above in this topic) is one answer! Vitest! I'm envisioning a third-party testing library/framework, and I think it could do that level of "hot function reloading"... but maybe that should be built into the Roc CLI! I don't know.
At a high level, any other favorite frameworks/libraries that any of you would like to see for Roc?
Robot Framework? Jest? Testify? Cucumber?
Alternatively, if you don't want an existing testing experience copy/pasted to Ro, what kind of testing principles/help/automation would you like to see in the Roc ecosystem?
I really enjoyed watching a talk on youtube recently on how Test-Driven Development has lost its way (and acquired a bad reputation as a result), and I agree - I'd like to see smooth+scalable TDD actually be as easy as it promises.
Time to learn the (new?) expect keyword :smile:
It looks like the current plan for first-party testing support is to encourage both app & platform authors to colocate function tests in the top level of the same files as the functions themselves?
exactly!
Sweet. Clear and simple!
Has there already been discussion of naming expect tests? For example, I would like to have something like
expect "div by zero is an error"
Num.divChecked 5 0 == Err DivByZero
If not, what do folks think of this? I am strongly in favor for the usual reasons of discoverability and test filtering. I can't see any immediate downside, but maybe I'm missing something
I wonder how far we can push expect on its own before we need some higher-level wrappers to allow for things like setup + cleanup around tests
Or testing many values at once by having a dict of cases to try. (There was a discussion about this in Zulip a few days back)
Or of course property-based testing
I was wondering about property-based testing too. It feels like it's possible to do a really good job with that here.
so, quick note: you can add a comment over it and the comment will appear in the output if the test fails
e.g.
# div by zero is an error
expect
Num.divChecked 5 0 == Err DivByZero
if we can name tests in their preceding comments, I think that's great too. The key for me is just having a way to name them, and being able to provide tooling around that (e.g. filtering)
Nice - I was about to say "that sounds a lot like a code comment", but I imagine there are broader uses, too
a thing Ruby's rspec lets you do is to run tests by filename and line number, which I think would be nice
Why would you want to run a test based on line number?
it's pretty handy to be able to focus only on a single test, or to retry with only the failing tests. By far the biggest win in rspec (for me at least) is being able to run only a single describe block at once. I don't think there's an analogous thing with expect.
the nice thing about running a test based on filename + line number is that it uniquely identifies the test, whereas sometimes test descriptions can be repeated across disparate tests in different files, leading to more tests being run than what you want
I guess I am used to file/package/module/namespace name + test name or something of that nature
I want to preserve the invariant that tests don't have to have names, because it opens up design space for interesting alternative ways to specify tests (e.g. via tables)
also because I want to make writing new tests as low-friction as possible!
I don't see tables as a contradiction to having names
Though I guess it is some for of friction
Richard Feldman said:
so, quick note: you can add a comment over it and the comment will appear in the output if the test fails
:thinking: Do we want to overload normal comments for this? It feels a bit dirty (as in: abuse of notation).
Maybe it's nicer if they are required to be 'documentation' comments (that starts with a double ##)?
my thinking there is that doc comments should be for actual documentation, which means they should be written with a certain level of care - e.g. a doc comment like ## works with an empty list looks wrong to me, because that's not at the level I expect for documentation! Whereas a comment like # works with an empty list both looks fine, and also is the style I would want to encourage for tests
I just thought of a counterargument: what if I want to use a comment to explain the reasoning behind the way the expect is used the way it is, but I don't want that explanation to appear in the failure message?
e.g.
# we're using `== Ok {}` here so that if it's an `Err` instead,
# we'll see the contents of the `Err` in the failure message
expect taskResult == Ok {}
this seems like a good argument for using ## comments for failure messages and # comments for notes like this
anyone have thoughts on this?
I have a thought on it but I'm not sure if it's just purely pedantic or if it matters!
This is not really a comment at all! A comment has no semantic meaning, but in this case it does. So really it's a special string syntax that's only used with the expect keyword.
This kind of jars with me. It feels like it's an extra thing squeezed in to the language as a special case rather than fitting in nicely. Like "this language can have arbitrary rules in some places".
Very much agreed! You are able to explain it much better than I was in my previous message :happy:
Optionally it could be a separate package/tool like doctest for Haskell. This way the language stays "clean" but those who want tests in their comments can do so (in a way the package sees fit).
Last updated: Jun 16 2026 at 16:19 UTC