You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/** * Returns the sum of 2 numbers * * @example sum(1, 2) * //=> 3 */exportconstsum=(a,b)=>{returna+b}
Note that the expected return value must be prefixed by //=>.
3. Run the tests
Import the doctest function in your test suite and point it at the file.
importdoctestfrom'@supabase/doctest-js';describe('Doctests',()=>{// file paths are relative to root of directorydoctest('src/sum.js')doctest('src/someOtherFile.js')})
Testing classes requires you to pass a newed up instance of the class into the test itself. Here is a simple example:
// Arithmetic.js - a basic class which we need to testclassArithmetic{constructor(){}/** * @example add(1, 2) * //=> 3 */add(a,b){returna+b}}export{Arithmetic}
Ready for production! Watch and star this repo to keep updated on releases.
Sponsors
We are building the features of Firebase using enterprise-grade, open source products. We support existing communities wherever possible, and if the products don’t exist we build them and open source them ourselves. Thanks to these sponsors who are making the OSS ecosystem better for everyone.
About
Run JSDoc style doc examples as tests within your test suite