switching to esbuild

This commit is contained in:
Geoff Doty 2021-01-02 03:42:41 -05:00
parent 12233bfb6c
commit 98c7523881
10 changed files with 22 additions and 5008 deletions

View File

@ -1,6 +1,6 @@
The MIT License
Copyright (c) 2018 testit authors
Copyright (c) 2021 Geoff Doty
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in

View File

@ -1,6 +1,6 @@
# Test.it
> A minimalistic testing library
> A minimalistic client-side testing library
**Test.it** is a small client-side testing library for people that want to live in code, not in tests. No over engineering here. Inspired by the simplicity of libraries like [Jasmine](https://jasmine.github.io/), but implementation ideas based on [TinyTest](https://github.com/joewalnes/jstinytest)
@ -134,4 +134,4 @@ Anyone is welcome to contribute, however, if you decide to get involved, please
## License
[MIT](LICENSE)
[MIT](LICENSE) Geoff Doty

58
dist/testit.js vendored
View File

@ -1,58 +0,0 @@
/*! Test.it v1.0.0 | MIT | https://github.com/n2geoff/testit */
const test = {
"log": console.log,
"version": "v1.0.0",
"_tests": {},
"run": function run(errors, next) {
if(typeof errors !== "boolean") {
next = errors;
errors = true;
}
let tests = this._tests || [];
let failed = [];
let passed = [];
Object.keys(tests).forEach((name) => {
let test = tests[name];
try {
test();
passed.push(`\n+OK ${name}`);
} catch (err) {
if (errors) {
failed.push(`\n-ERR ${name} \n --- \n ${err.stack} \n ---`);
} else {
failed.push(`\n-ERR ${name}`);
}
}
});
if(typeof next === "function") {
return next({
pass: passed,
fail: failed
});
} else {
test.log(...passed, ...failed);
test.log(`\n# tests ${failed.length + passed.length} pass ${passed.length} fail ${failed.length}`);
return failed.length ? false : true;
}
},
"it": function it(tests) {
this._tests = tests;
return this;
},
"assert": (expression, msg) => {
try {
if(!expression) {
throw new Error(msg || "Assertion Failed");
}
} catch (e) {
throw new Error(msg);
}
}
};
export default test;

10
dist/testit.min.js vendored
View File

@ -1 +1,9 @@
const test={log:console.log,version:"v1.0.0",_tests:{},run:function(t,e){"boolean"!=typeof t&&(e=t,t=!0);let s=this._tests||[],n=[],o=[];return Object.keys(s).forEach(e=>{let r=s[e];try{r(),o.push(`\n+OK ${e}`)}catch(s){t?n.push(`\n-ERR ${e} \n --- \n ${s.stack} \n ---`):n.push(`\n-ERR ${e}`)}}),"function"==typeof e?e({pass:o,fail:n}):(test.log(...o,...n),test.log(`\n# tests ${n.length+o.length} pass ${o.length} fail ${n.length}`),!n.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)}}};export default test;
/*! Test.it v1.0.0 | MIT | https://github.com/n2geoff/testit */const i={log:console.log,version:"v1.0.0",_tests:{},run:function(t,n){typeof t!="boolean"&&(n=t,t=!0);let r=this._tests||[],e=[],s=[];return Object.keys(r).forEach(l=>{let h=r[l];try{h(),s.push(`
+OK ${l}`)}catch(f){t?e.push(`
-ERR ${l}
---
${f.stack}
---`):e.push(`
-ERR ${l}`)}}),typeof n=="function"?n({pass:s,fail:e}):(i.log(...s,...e),i.log(`
# tests ${e.length+s.length} pass ${s.length} fail ${e.length}`),!e.length)},it:function(t){return this._tests=t,this},assert:(o,t)=>{try{if(!o)throw new Error(t||"Assertion Failed")}catch(n){throw new Error(t)}}};var u=i;export{u as default};
//# sourceMappingURL=testit.min.js.map

7
dist/testit.min.js.map vendored Normal file
View File

@ -0,0 +1,7 @@
{
"version": 3,
"sources": ["../src/testit.js"],
"sourcesContent": ["/*! Test.it v1.0.0 | MIT | https://github.com/n2geoff/testit */\r\nconst test = {\r\n \"log\": console.log, // eslint-disable-line\r\n \"version\": \"v1.0.0\",\r\n \"_tests\": {},\r\n \"run\": function run(errors, next) {\r\n // TODO: rewrite to allow a show errors flag (optional)\r\n if(typeof errors !== \"boolean\") {\r\n next = errors;\r\n errors = true;\r\n }\r\n\r\n let tests = this._tests || [];\r\n // capture results\r\n let failed = [];\r\n let passed = [];\r\n\r\n // loop through tests\r\n Object.keys(tests).forEach((name) => {\r\n let test = tests[name];\r\n\r\n // execute\r\n try {\r\n test();\r\n passed.push(`\\n+OK ${name}`);\r\n } catch (err) {\r\n if (errors) {\r\n failed.push(`\\n-ERR ${name} \\n --- \\n ${err.stack} \\n ---`);\r\n } else {\r\n failed.push(`\\n-ERR ${name}`);\r\n }\r\n }\r\n });\r\n\r\n // summary\r\n if(typeof next === \"function\") {\r\n return next({\r\n pass: passed,\r\n fail: failed\r\n });\r\n } else {\r\n test.log(...passed, ...failed);\r\n test.log(`\\n# tests ${failed.length + passed.length} pass ${passed.length} fail ${failed.length}`);\r\n\r\n return failed.length ? false : true;\r\n }\r\n },\r\n \"it\": function it(tests) {\r\n this._tests = tests;\r\n return this;\r\n },\r\n \"assert\": (expression, msg) => {\r\n try {\r\n if(!expression) {\r\n throw new Error(msg || \"Assertion Failed\");\r\n }\r\n } catch (e) {\r\n throw new Error(msg);\r\n }\r\n }\r\n};\r\n\r\nexport default test;\r\n"],
"mappings": "AAAA,+DACA,MAAM,EAAO,CACT,IAAO,QAAQ,IACf,QAAW,SACX,OAAU,GACV,IAAO,cAEH,AAAG,MAAO,IAAW,WACjB,GAAO,EACP,EAAS,IAGb,MAAY,KAAK,QAAU,KAEd,KACA,GAoBb,MAjBA,QAAO,KAAK,GAAO,QAAQ,IACvB,MAAW,EAAM,GAGjB,IACI,IACA,EAAO,KAAK;AAAA,MAAS,cAErB,AAAI,EACA,EAAO,KAAK;AAAA,OAAU;AAAA;AAAA,GAAkB,EAAI;AAAA,OAE5C,EAAO,KAAK;AAAA,OAAU,QAM/B,MAAO,IAAS,WACR,EAAK,CACR,KAAM,EACN,KAAM,IAGV,GAAK,IAAI,GAAG,EAAQ,GAAG,GACvB,EAAK,IAAI;AAAA,UAAa,EAAO,OAAS,EAAO,eAAe,EAAO,eAAe,EAAO,UAElF,GAAO,SAGtB,GAAM,YACF,YAAK,OAAS,EACP,MAEX,OAAU,QACN,IACI,GAAG,CAAC,EACA,KAAM,IAAI,OAAM,GAAO,6BAG3B,KAAM,IAAI,OAAM,MAK5B,MAAe",
"names": []
}

66
dist/testit.umd.js vendored
View File

@ -1,66 +0,0 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define('umd', factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.umd = factory());
}(this, (function () { 'use strict';
/*! Test.it v1.0.0 | MIT | https://github.com/n2geoff/testit */
const test = {
"log": console.log,
"version": "v1.0.0",
"_tests": {},
"run": function run(errors, next) {
if(typeof errors !== "boolean") {
next = errors;
errors = true;
}
let tests = this._tests || [];
let failed = [];
let passed = [];
Object.keys(tests).forEach((name) => {
let test = tests[name];
try {
test();
passed.push(`\n+OK ${name}`);
} catch (err) {
if (errors) {
failed.push(`\n-ERR ${name} \n --- \n ${err.stack} \n ---`);
} else {
failed.push(`\n-ERR ${name}`);
}
}
});
if(typeof next === "function") {
return next({
pass: passed,
fail: failed
});
} else {
test.log(...passed, ...failed);
test.log(`\n# tests ${failed.length + passed.length} pass ${passed.length} fail ${failed.length}`);
return failed.length ? false : true;
}
},
"it": function it(tests) {
this._tests = tests;
return this;
},
"assert": (expression, msg) => {
try {
if(!expression) {
throw new Error(msg || "Assertion Failed");
}
} catch (e) {
throw new Error(msg);
}
}
};
return test;
})));

View File

@ -1 +0,0 @@
!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});

View File

@ -1,26 +0,0 @@
const gulp = require("gulp");
const minify = require("gulp-minify");
const strip = require("gulp-strip-comments");
const rollup = require("gulp-rollup-2").rollup;
gulp.task("default", function build() {
return gulp.src("./src/testit.js")
.pipe(rollup({
input: "./src/testit.js",
output: [
{
file: "testit.js",
name: "es",
format: "es"
},
{
file: "testit.umd.js",
name: "umd",
format: "umd"
},
]
}))
.pipe(strip({safe: true}))
.pipe(minify({ext: {min: ".min.js"}}))
.pipe(gulp.dest("dist"))
});

4847
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +1,19 @@
{
"name": "testit",
"version": "1.0.0",
"description": "minimalistic testing library",
"description": "minimalistic clinet-side testing library",
"main": "src/testit.js",
"directories": {
"test": "test"
},
"scripts": {
"build": "npx gulp default",
"build": "esbuild src/testit.js --minify --sourcemap --format=esm --outfile=dist/testit.min.js",
"lint": "npx eslint src/testit.js",
"test": "npx live-server --open=test/ --port=5000"
},
"dependencies": {},
"devDependencies": {
"eslint": "^7.16.0",
"gulp": "^4.0.2",
"gulp-minify": "^3.1.0",
"gulp-rollup-2": "^1.2.1",
"gulp-strip-comments": "^2.5.2",
"live-server": "^1.2.1"
},
"repository": {