testit/dist/testit.umd.min.js

1 line
819 B
JavaScript

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define("umd",e):(t="undefined"!=typeof globalThis?globalThis:t||self).umd=e()}(this,function(){"use strict";const t={log:console.log,version:"v1.0.0",_tests:{},run:function(e,n){"boolean"!=typeof e&&(n=e,e=!0);let o=this._tests||[],s=[],i=[];return Object.keys(o).forEach(t=>{let n=o[t];try{n(),i.push(`\n+OK ${t}`)}catch(n){e?s.push(`\n-ERR ${t} \n --- \n ${n.stack} \n ---`):s.push(`\n-ERR ${t}`)}}),"function"==typeof n?n({pass:i,fail:s}):(t.log(...i,...s),t.log(`\n# tests ${s.length+i.length} pass ${i.length} fail ${s.length}`),!s.length)},it:function(t){return this._tests=t,this},assert:(t,e)=>{try{if(!t)throw new Error(e||"Assertion Failed")}catch(t){throw new Error(e)}}};return t});