locutusjs / locutus

Bringing stdlibs of other programming languages to JavaScript for educational purposes

Home Page:https://locutus.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unit tests in separate files?

kukawski opened this issue · comments

When porting functions like sprintf, serialize, unserialize or strtotime, I found it quite limiting to add unit tests in the comments. The functions are so complex that they require really many test cases to prevent regressions and adding them as comments inside the function body is IMHO not a good idea, because of the bloat and loss of readability.

How about moving tests out of the comments, just keep them in separate file, e.g. in same folder named {function}.test.js? We could still keep the comments to show examples how to call the functions properly. The comments could still be parsed and executed to make sure that examples still work.

I'm fine to have these files in addition, for sure 👌 Shall we use Jest then?