Do any JavaScript test frameworks provide a rough equivalent to Python's doctest?
function add(a, b) {
/**
Returns the sum of `a` and `b`:
> add(1, 3)
4
Add coerces types to numeric values where possible:
> add('51' + 3)
54
*/
return (a - 0) + (b - 0);
}
I can't get the point of Ian Bicking's package, doctestjs. He just provides us a different way of writing normal external tests, not real doctests.
I use a lot python doctests, they are quite important for me, I don't know what doctestjs could be useful for, but I found some true doctests implemented with this project: https://github.com/davidchambers/doctest .
Even if that is not the most trendy doctest project for javascript, I strongly prefer it.
Update: after more that one year since this answer, i had the opportunity to contribute to the project from David Chambers, it is really well written. I also used it at work in a complex application using require.js, and for this we added support for AMD modules. I think he added support for Common JS modules as well. Thus i can only confirm my opinion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With