mirror of https://github.com/n2geoff/testit.git
convert to rollup build system
This commit is contained in:
parent
1a388656f2
commit
ec4e087e90
16
gulpfile.js
16
gulpfile.js
|
@ -1,9 +1,25 @@
|
||||||
const gulp = require("gulp");
|
const gulp = require("gulp");
|
||||||
const minify = require("gulp-minify");
|
const minify = require("gulp-minify");
|
||||||
const strip = require("gulp-strip-comments");
|
const strip = require("gulp-strip-comments");
|
||||||
|
const rollup = require("gulp-rollup-2").rollup;
|
||||||
|
|
||||||
gulp.task("default", function build() {
|
gulp.task("default", function build() {
|
||||||
return gulp.src("./src/testit.js")
|
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(strip({safe: true}))
|
||||||
.pipe(minify({ext: {min: ".min.js"}}))
|
.pipe(minify({ext: {min: ".min.js"}}))
|
||||||
.pipe(gulp.dest("dist"))
|
.pipe(gulp.dest("dist"))
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "testit",
|
"name": "testit",
|
||||||
"version": "0.8.2",
|
"version": "0.9.0",
|
||||||
"description": "a minimalistic testing library",
|
"description": "minimalistic testing library",
|
||||||
"main": "src/testit.js",
|
"main": "src/testit.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
"test": "test"
|
"test": "test"
|
||||||
|
@ -15,6 +15,7 @@
|
||||||
"eslint": "^7.8.1",
|
"eslint": "^7.8.1",
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
"gulp-minify": "^3.1.0",
|
"gulp-minify": "^3.1.0",
|
||||||
|
"gulp-rollup-2": "^1.1.0",
|
||||||
"gulp-strip-comments": "^2.5.2"
|
"gulp-strip-comments": "^2.5.2"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -1,16 +1,6 @@
|
||||||
/*! Test.it v 0.8.0 | MIT | https://github.com/n2geoff/testit */
|
/*! Test.it v 0.9.0 | MIT | https://github.com/n2geoff/testit */
|
||||||
;(function (root, factory) {
|
const test = {
|
||||||
"use strict";
|
"log": console.log,
|
||||||
// support browser & commonjs
|
|
||||||
if (typeof module === "object" && module.exports) {
|
|
||||||
module.exports = factory(root.test);
|
|
||||||
} else {
|
|
||||||
root.test = factory(root.test);
|
|
||||||
}
|
|
||||||
}(this, function () {
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const test = {
|
|
||||||
"_tests": {},
|
"_tests": {},
|
||||||
"run": function run(errors, next) {
|
"run": function run(errors, next) {
|
||||||
// TODO: rewrite to allow a show errors flag (optional)
|
// TODO: rewrite to allow a show errors flag (optional)
|
||||||
|
@ -19,7 +9,7 @@
|
||||||
errors = true;
|
errors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let tests = this._tests;
|
let tests = this._tests || [];
|
||||||
// capture results
|
// capture results
|
||||||
let failed = [];
|
let failed = [];
|
||||||
let passed = [];
|
let passed = [];
|
||||||
|
@ -48,8 +38,8 @@
|
||||||
fail: failed
|
fail: failed
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log(...passed, ...failed);
|
test.log(...passed, ...failed);
|
||||||
console.log(`\n# tests ${failed.length + passed.length} pass ${passed.length} fail ${failed.length}`);
|
test.log(`\n# tests ${failed.length + passed.length} pass ${passed.length} fail ${failed.length}`);
|
||||||
|
|
||||||
return failed.length ? false : true;
|
return failed.length ? false : true;
|
||||||
}
|
}
|
||||||
|
@ -65,8 +55,8 @@
|
||||||
"a": (type) => { return test.expects(val).to.be.an(type); },
|
"a": (type) => { return test.expects(val).to.be.an(type); },
|
||||||
"an": (type) => {
|
"an": (type) => {
|
||||||
|
|
||||||
if(['array'].indexOf(type) !== -1) {
|
if(["array"].indexOf(type) !== -1) {
|
||||||
if(val.constructor.name.toLowerCase() !== 'array') {
|
if(val.constructor.name.toLowerCase() !== "array") {
|
||||||
throw new Error(`expected ${typeof val} to be an ${type}`);
|
throw new Error(`expected ${typeof val} to be an ${type}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +89,6 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return test;
|
export default test;
|
||||||
}));
|
|
||||||
|
|
Loading…
Reference in New Issue