3 ms·
Show HN: Doctest-JS. Write unit tests using comments in your code
- kiwicopple 7y agoHey HN. This is a small but useful library for writing tests using JSDoc. 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.