6 ms·
I haven't seen that before, but I really like it. I've thought before that it'd be a good idea to include tests adjacent to the code they're testing before, bu
by wry_discontent 9y ago
I haven't seen that before, but I really like it. I've thought before that it'd be a good idea to include tests adjacent to the code they're testing before, but I'm not sure of a good way to do that, particularly in Javascript.
- masklinn 9y agoIME it's an OK way to show examples which are validated (and thus don't get broken as the API changes), but it's really not a good way to have actual tests. Terrible debugging experience aside, actual unit tests just make very little sense as part of a documentation.
- ch4s3 9y agoThey're really only for documentation and the simplest of single function unit tests.
- pmontra 9y agoThe idea is to provide a DRY way to ensure that the examples are correct. Few things are worse than a wrong example.
- masklinn 9y agoThat's a fine idea and exactly why doctests exist but I am specifically replying to a comment talking about tests. Not testing examples, having actual tests included in the documentation. Which, again, experience taught me is a terrible idea.