Comparing version 2.0.0 to 2.1.0
@@ -5,7 +5,12 @@ # Change Log for ospec | ||
## Upcoming... | ||
_2018-xx-xx_ | ||
<!-- Add new lines here. Version number will be decided later --> | ||
- ... | ||
### Features | ||
>>>>>>> [ospec/bin] Back to ES5 (and complimentary cleanup), fix #2160 | ||
- Pinpoint the `o.only()` call site ([#2157](https://github.com/MithrilJS/mithril.js/pull/2157)) | ||
- Improved wording, spacing and color-coding of report messages and errors ([#2147](https://github.com/MithrilJS/mithril.js/pull/2147), [@maranomynet](https://github.com/maranomynet)) | ||
### Bug fixes | ||
- Convert the exectuable back to plain ES5 [#2160](https://github.com/MithrilJS/mithril.js/issues/2160) ([#2161](https://github.com/MithrilJS/mithril.js/pull/2161)) | ||
## 2.0.0 | ||
@@ -16,3 +21,3 @@ _2018-05-09_ | ||
- the CLI runner now accepts globs as arguments ([#2141](https://github.com/MithrilJS/mithril.js/pull/2141), [@maranomynet](https://github.com/maranomynet)) | ||
- Added support for custom reporters ([#2020](https://github.com/MithrilJS/mithril.js/pull/2020)) | ||
- Added support for custom reporters ([#2020](https://github.com/MithrilJS/mithril.js/pull/2020), [@zyrolasting](https://github.com/zyrolasting)) | ||
- Make ospec more [Flems](https://flems.io)-friendly ([#2034](https://github.com/MithrilJS/mithril.js/pull/2034)) | ||
@@ -19,0 +24,0 @@ - Works either as a global or in CommonJS environments |
44
ospec.js
@@ -37,3 +37,8 @@ /* eslint-disable global-require, no-bitwise, no-process-exit */ | ||
o.only = function(subject, predicate, silent) { | ||
if (!silent) console.log(highlight("/!\\ WARNING /!\\ o.only() mode")) | ||
if (!silent) { | ||
console.log(highlight("/!\\ WARNING /!\\ o.only() mode")) | ||
try {throw new Error} catch (e) { | ||
console.log(this.cleanStackTrace(e) + "\n") | ||
} | ||
} | ||
o(subject, only = predicate) | ||
@@ -235,3 +240,3 @@ } | ||
if (compare(this.value, value)) record(null) | ||
else record(serialize(this.value) + "\n" + verb + "\n" + serialize(value)) | ||
else record(serialize(this.value) + "\n " + verb + "\n" + serialize(value)) | ||
return function(message) { | ||
@@ -263,5 +268,14 @@ var result = results[results.length - 1] | ||
} | ||
function highlight(message) { | ||
return hasProcess ? (process.stdout.isTTY ? "\x1b[31m" + message + "\x1b[0m" : message) : "%c" + message + "%c " | ||
var colorCodes = { | ||
red: "31m", | ||
red2: "31;1m", | ||
green: "32;1m" | ||
} | ||
function highlight(message, color) { | ||
var code = colorCodes[color] || colorCodes.red; | ||
return hasProcess ? (process.stdout.isTTY ? "\x1b[" + code + message + "\x1b[0m" : message) : "%c" + message + "%c " | ||
} | ||
function cStyle(color, bold) { | ||
return hasProcess||!color ? "" : "color:"+color+(bold ? ";font-weight:bold" : "") | ||
} | ||
@@ -273,10 +287,24 @@ o.report = function (results) { | ||
var stackTrace = o.cleanStackTrace(r.error) | ||
console.error(r.context + ":\n" + highlight(r.message) + (stackTrace ? "\n\n" + stackTrace + "\n\n" : ""), hasProcess ? "" : "color:red", hasProcess ? "" : "color:black") | ||
console.error( | ||
(hasProcess ? "\n" : "") + | ||
highlight(r.context + ":", "red2") + "\n" + | ||
highlight(r.message, "red") + | ||
(stackTrace ? "\n" + stackTrace + "\n" : ""), | ||
cStyle("black", true), "", // reset to default | ||
cStyle("red"), cStyle("black") | ||
) | ||
errCount++ | ||
} | ||
} | ||
var pl = results.length === 1 ? "" : "s" | ||
var resultSummary = (errCount === 0) ? | ||
highlight((pl ? "All " : "The ") + results.length + " assertion" + pl + " passed", "green"): | ||
highlight(errCount + " out of " + results.length + " assertion" + pl + " failed", "red2") | ||
var runningTime = " in " + Math.round(Date.now() - start) + "ms" | ||
console.log( | ||
(name ? name + ": " : "") + | ||
results.length + " assertions completed in " + Math.round(new Date - start) + "ms, " + | ||
"of which " + results.filter(function(result){return result.error}).length + " failed" | ||
(hasProcess ? "––––––\n" : "") + | ||
(name ? name + ": " : "") + resultSummary + runningTime, | ||
cStyle((errCount === 0 ? "green" : "red"), true), "" | ||
) | ||
@@ -283,0 +311,0 @@ return errCount |
{ | ||
"name": "ospec", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Noiseless testing framework", | ||
@@ -5,0 +5,0 @@ "main": "ospec.js", |
@@ -10,3 +10,3 @@ ospec [![NPM Version](https://img.shields.io/npm/v/ospec.svg)](https://www.npmjs.com/package/ospec) [![NPM License](https://img.shields.io/npm/l/ospec.svg)](https://www.npmjs.com/package/ospec) | ||
- ~330 LOC including the CLI runner | ||
- ~360 LOC including the CLI runner | ||
- terser and faster test code than with mocha, jasmine or tape | ||
@@ -13,0 +13,0 @@ - test code reads like bullet points |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38398
528