Show HN: Doctest-JS. Write unit tests using comments in your code
github.com
github.com
For example you can write:
/**
* Returns the sum of 2 numbers
*
* @example sum(1, 2)
* //=> 3
*/
export const sum = (a, b) => {
return a + b
}
And then this library will assert that the @example returns the correct code.This has been super useful for us because it is cognitively easier to write/run the tests in the context of the function itself.
It's not very well tested with classes, but we are looking for any feedback and will continue to improve.