Comparing version 4.1.1 to 4.1.2
12
ospec.js
@@ -253,3 +253,2 @@ "use strict" | ||
stats = { | ||
asyncSuccesses: 0, | ||
bailCount: 0, | ||
@@ -420,4 +419,2 @@ onlyCalledAt: onlyCalledAt | ||
// temporary, for the "old style count" report | ||
if (!threw && task.error != null) {stats.asyncSuccesses++} | ||
@@ -722,3 +719,3 @@ if (!isFinalized) finalize(err, threw, false) | ||
o.report = function (results, stats) { | ||
if (stats == null) stats = {bailCount: 0, asyncSuccesses: 0} | ||
if (stats == null) stats = {bailCount: 0} | ||
var errCount = -stats.bailCount | ||
@@ -745,3 +742,2 @@ for (var i = 0, r; r = results[i]; i++) { | ||
var oldTotal = " (old style total: " + (results.length + stats.asyncSuccesses) + ")" | ||
var total = results.length - stats.bailCount | ||
@@ -755,8 +751,8 @@ var message = [], log = [] | ||
if (errCount === 0 && stats.bailCount === 0) { | ||
message.push(highlight((pl ? "All " : "The ") + total + " assertion" + pl + " passed" + oldTotal, "green")) | ||
message.push(highlight((pl ? "All " : "The ") + total + " assertion" + pl + " passed", "green")) | ||
log.push(cStyle("green" , true), cStyle(null)) | ||
} else if (errCount === 0) { | ||
message.push((pl ? "All " : "The ") + total + " assertion" + pl + " passed" + oldTotal) | ||
message.push((pl ? "All " : "The ") + total + " assertion" + pl + " passed") | ||
} else { | ||
message.push(highlight(errCount + " out of " + total + " assertion" + pl + " failed" + oldTotal, "red2")) | ||
message.push(highlight(errCount + " out of " + total + " assertion" + pl + " failed", "red2")) | ||
log.push(cStyle("red" , true), cStyle(null)) | ||
@@ -763,0 +759,0 @@ } |
{ | ||
"name": "ospec", | ||
"version": "4.1.1", | ||
"version": "4.1.2", | ||
"description": "Noiseless testing framework", | ||
@@ -22,12 +22,17 @@ "main": "ospec.js", | ||
"scripts": { | ||
"test": "ospec tests/test-*.js", | ||
"test-api": "ospec tests/test-api.js", | ||
"test-cli": "ospec tests/test-cli.js", | ||
"postinstall": "node scripts/rename-stable-binaries.js", | ||
"test": "ospec-stable tests/test-*.js", | ||
"test-api": "ospec-stable tests/test-api.js", | ||
"test-cli": "ospec-stable tests/test-cli.js", | ||
"self-test": "node ./bin/ospec tests/test-*.js", | ||
"self-test-api": "node ./bin/ospec tests/test-api.js", | ||
"self-test-cli": "node ./bin/ospec tests/test-cli.js", | ||
"lint": "eslint . bin/ospec" | ||
}, | ||
"devDependencies": { | ||
"compose-regexp": "0.4.0", | ||
"cmd-shim": "4.0.2", | ||
"compose-regexp": "0.6.22", | ||
"eslint": "^6.8.0", | ||
"ospec": "4.0.1" | ||
"ospec-stable": "npm:ospec@4.1.1-and-then-some" | ||
} | ||
} |
311
README.md
@@ -1,13 +0,9 @@ | ||
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) [![npm Downloads](https://img.shields.io/npm/dm/ospec.svg)](https://www.npmjs.com/package/ospec) [![Donate at OpenCollective](https://img.shields.io/opencollective/all/mithriljs.svg?colorB=brightgreen)](https://opencollective.com/mithriljs) | ||
===== | ||
# ospec | ||
<p align="center"> | ||
<a href="https://travis-ci.org/MithrilJS/ospec"> | ||
<img src="https://img.shields.io/travis/MithrilJS/ospec/master.svg" alt="Build Status"> | ||
</a> | ||
<a href="https://gitter.im/mithriljs/mithril.js"> | ||
<img src="https://img.shields.io/gitter/room/mithriljs/mithril.js.svg" alt="Gitter" /> | ||
</a> | ||
</p> | ||
[![npm License](https://img.shields.io/npm/l/ospec.svg)](https://www.npmjs.com/package/ospec) [![npm Version](https://img.shields.io/npm/v/ospec.svg)](https://www.npmjs.com/package/ospec) [![Build Status](https://img.shields.io/travis/MithrilJS/ospec/master.svg)](https://travis-ci.org/MithrilJS/ospec) [![npm Downloads](https://img.shields.io/npm/dm/ospec.svg)](https://www.npmjs.com/package/ospec) | ||
[![Donate at OpenCollective](https://img.shields.io/opencollective/all/mithriljs.svg?colorB=brightgreen)](https://opencollective.com/mithriljs) [![Gitter](https://img.shields.io/gitter/room/mithriljs/mithril.js.svg)](https://gitter.im/mithriljs/mithril.js) | ||
--- | ||
[About](#about) | [Usage](#usage) | [CLI](#command-line-interface) | [API](#api) | [Goals](#goals) | ||
@@ -19,3 +15,3 @@ | ||
- ~580 LOC including the CLI runner | ||
- ~660 LOC including the CLI runner | ||
- terser and faster test code than with mocha, jasmine or tape | ||
@@ -25,9 +21,9 @@ - test code reads like bullet points | ||
- supports: | ||
- test grouping | ||
- assertions | ||
- spies | ||
- `equals`, `notEquals`, `deepEquals` and `notDeepEquals` assertion types | ||
- `before`/`after`/`beforeEach`/`afterEach` hooks | ||
- test exclusivity (i.e. `.only`) | ||
- async tests and hooks | ||
- test grouping | ||
- assertions | ||
- spies | ||
- `equals`, `notEquals`, `deepEquals` and `notDeepEquals` assertion types | ||
- `before`/`after`/`beforeEach`/`afterEach` hooks | ||
- test exclusivity (i.e. `.only`) | ||
- async tests and hooks | ||
- explicitly regulates test-space configuration to encourage focus on testing, and to provide uniform test suites across projects | ||
@@ -45,6 +41,6 @@ | ||
o("addition", function() { | ||
o(1 + 1).equals(2) | ||
o(1 + 1).equals(2) | ||
}) | ||
o("subtraction", function() { | ||
o(1 - 1).notEquals(2) | ||
o(1 - 1).notEquals(2) | ||
}) | ||
@@ -57,7 +53,7 @@ ``` | ||
o("addition", function() { | ||
o(1 + 1).equals(2)("addition should work") | ||
o(1 + 1).equals(2)("addition should work") | ||
/* in ES6, the following syntax is also possible | ||
o(1 + 1).equals(2) `addition should work` | ||
*/ | ||
/* in ES6, the following syntax is also possible | ||
o(1 + 1).equals(2) `addition should work` | ||
*/ | ||
}) | ||
@@ -81,8 +77,8 @@ /* for a failing test, an assertion with a description outputs this: | ||
o.spec("math", function() { | ||
o("addition", function() { | ||
o(1 + 1).equals(2) | ||
}) | ||
o("subtraction", function() { | ||
o(1 - 1).notEquals(2) | ||
}) | ||
o("addition", function() { | ||
o(1 + 1).equals(2) | ||
}) | ||
o("subtraction", function() { | ||
o(1 - 1).notEquals(2) | ||
}) | ||
}) | ||
@@ -99,10 +95,10 @@ ``` | ||
o.spec("math", function() { | ||
o.spec("arithmetics", function() { | ||
o("addition", function() { | ||
o(1 + 1).equals(2) | ||
}) | ||
o("subtraction", function() { | ||
o(1 - 1).notEquals(2) | ||
}) | ||
}) | ||
o.spec("arithmetics", function() { | ||
o("addition", function() { | ||
o(1 + 1).equals(2) | ||
}) | ||
o("subtraction", function() { | ||
o(1 - 1).notEquals(2) | ||
}) | ||
}) | ||
}) | ||
@@ -123,10 +119,10 @@ ``` | ||
o.spec("call()", function() { | ||
o("works", function() { | ||
var spy = o.spy() | ||
call(spy, 1) | ||
o("works", function() { | ||
var spy = o.spy() | ||
call(spy, 1) | ||
o(spy.callCount).equals(1) | ||
o(spy.args[0]).equals(1) | ||
o(spy.calls[0]).deepEquals([1]) | ||
}) | ||
o(spy.callCount).equals(1) | ||
o(spy.args[0]).equals(1) | ||
o(spy.calls[0]).deepEquals([1]) | ||
}) | ||
}) | ||
@@ -141,3 +137,3 @@ ``` | ||
function inc() { | ||
count++ | ||
count++ | ||
} | ||
@@ -149,8 +145,8 @@ | ||
o.spec("call()", function() { | ||
o("works", function() { | ||
var spy = o.spy(inc) | ||
spy() | ||
o("works", function() { | ||
var spy = o.spy(inc) | ||
spy() | ||
o(count).equals(1) | ||
}) | ||
o(count).equals(1) | ||
}) | ||
}) | ||
@@ -166,3 +162,3 @@ | ||
o("setTimeout calls callback", function(done) { | ||
setTimeout(done, 10) | ||
setTimeout(done, 10) | ||
}) | ||
@@ -175,5 +171,5 @@ ``` | ||
o("promise test", function() { | ||
return new Promise(function(resolve) { | ||
setTimeout(resolve, 10) | ||
}) | ||
return new Promise(function(resolve) { | ||
setTimeout(resolve, 10) | ||
}) | ||
}) | ||
@@ -184,3 +180,3 @@ ``` | ||
o("promise test", async function() { | ||
await someOtherAsyncFunction() | ||
await someOtherAsyncFunction() | ||
}) | ||
@@ -196,17 +192,17 @@ ``` | ||
o.spec("a spec that must timeout quickly", function() { | ||
// wait 20ms before bailing out of the tests of this suite and | ||
// its descendants | ||
o.specTimeout(20) | ||
o("some test", function(done) { | ||
setTimeout(done, 10) // this will pass | ||
}) | ||
// wait 20ms before bailing out of the tests of this suite and | ||
// its descendants | ||
o.specTimeout(20) | ||
o("some test", function(done) { | ||
setTimeout(done, 10) // this will pass | ||
}) | ||
o.spec("a child suite where the delay also applies", function () { | ||
o("some test", function(done) { | ||
setTimeout(done, 30) // this will time out. | ||
}) | ||
}) | ||
o.spec("a child suite where the delay also applies", function () { | ||
o("some test", function(done) { | ||
setTimeout(done, 30) // this will time out. | ||
}) | ||
}) | ||
}) | ||
o.spec("a spec that uses the default delay", function() { | ||
// ... | ||
// ... | ||
}) | ||
@@ -219,5 +215,5 @@ ``` | ||
o("setTimeout calls callback", function(done) { | ||
o.timeout(500) //wait 500ms before bailing out of the test | ||
o.timeout(500) //wait 500ms before bailing out of the test | ||
setTimeout(done, 300) | ||
setTimeout(done, 300) | ||
}) | ||
@@ -230,4 +226,4 @@ ``` | ||
o("promise test", function() { | ||
o.timeout(1000) | ||
return someOtherAsyncFunctionThatTakes900ms() | ||
o.timeout(1000) | ||
return someOtherAsyncFunctionThatTakes900ms() | ||
}) | ||
@@ -238,4 +234,4 @@ ``` | ||
o("promise test", async function() { | ||
o.timeout(1000) | ||
await someOtherAsyncFunctionThatTakes900ms() | ||
o.timeout(1000) | ||
await someOtherAsyncFunctionThatTakes900ms() | ||
}) | ||
@@ -252,17 +248,17 @@ ``` | ||
o.spec("math", function() { | ||
var acc | ||
o.beforeEach(function() { | ||
acc = 0 | ||
}) | ||
var acc | ||
o.beforeEach(function() { | ||
acc = 0 | ||
}) | ||
o("addition", function() { | ||
acc += 1 | ||
o("addition", function() { | ||
acc += 1 | ||
o(acc).equals(1) | ||
}) | ||
o("subtraction", function() { | ||
acc -= 1 | ||
o(acc).equals(1) | ||
}) | ||
o("subtraction", function() { | ||
acc -= 1 | ||
o(acc).equals(-1) | ||
}) | ||
o(acc).equals(-1) | ||
}) | ||
}) | ||
@@ -279,21 +275,21 @@ ``` | ||
o.spec("math", function() { | ||
var acc | ||
o.beforeEach(function(done) { | ||
setTimeout(function() { | ||
acc = 0 | ||
done() | ||
}) | ||
}) | ||
var acc | ||
o.beforeEach(function(done) { | ||
setTimeout(function() { | ||
acc = 0 | ||
done() | ||
}) | ||
}) | ||
//tests only run after async hooks complete | ||
o("addition", function() { | ||
acc += 1 | ||
//tests only run after async hooks complete | ||
o("addition", function() { | ||
acc += 1 | ||
o(acc).equals(1) | ||
}) | ||
o("subtraction", function() { | ||
acc -= 1 | ||
o(acc).equals(1) | ||
}) | ||
o("subtraction", function() { | ||
acc -= 1 | ||
o(acc).equals(-1) | ||
}) | ||
o(acc).equals(-1) | ||
}) | ||
}) | ||
@@ -308,21 +304,21 @@ ``` | ||
o.spec("math", function() { | ||
// will not run | ||
o("addition", function() { | ||
o(1 + 1).equals(2) | ||
}) | ||
// will not run | ||
o("addition", function() { | ||
o(1 + 1).equals(2) | ||
}) | ||
// this test will be run, regardless of how many groups there are | ||
o.only("subtraction", function() { | ||
o(1 - 1).notEquals(2) | ||
}) | ||
// this test will be run, regardless of how many groups there are | ||
o.only("subtraction", function() { | ||
o(1 - 1).notEquals(2) | ||
}) | ||
// will not run | ||
o("multiplication", function() { | ||
o(2 * 2).equals(4) | ||
}) | ||
// will not run | ||
o("multiplication", function() { | ||
o(2 * 2).equals(4) | ||
}) | ||
// this test will be run, regardless of how many groups there are | ||
o.only("division", function() { | ||
o(6 / 2).notEquals(2) | ||
}) | ||
// this test will be run, regardless of how many groups there are | ||
o.only("division", function() { | ||
o(6 / 2).notEquals(2) | ||
}) | ||
}) | ||
@@ -336,3 +332,3 @@ ``` | ||
o("addition", function() { | ||
o(1 + 1).equals(2) | ||
o(1 + 1).equals(2) | ||
}) | ||
@@ -351,3 +347,3 @@ | ||
_o("a test", function() { | ||
_o(1).equals(1) | ||
_o(1).equals(1) | ||
}) | ||
@@ -360,13 +356,15 @@ _o.run() | ||
Create a script in your package.json: | ||
```javascript | ||
"scripts": { | ||
"test": "ospec", | ||
... | ||
} | ||
``` | ||
"scripts": { | ||
"test": "ospec", | ||
... | ||
} | ||
``` | ||
...and run it from the command line: | ||
```shell | ||
npm test | ||
``` | ||
$ npm test | ||
``` | ||
@@ -381,3 +379,3 @@ **NOTE:** `o.run()` is automatically called by the cli - no need to call it in your test code. | ||
``` | ||
```shell | ||
ospec '**/spec/**/*.js' '**/*.spec.js' | ||
@@ -388,3 +386,3 @@ ``` | ||
``` | ||
```shell | ||
ospec --ignore 'folder1/**' 'folder2/**' | ||
@@ -395,3 +393,3 @@ ``` | ||
``` | ||
```shell | ||
ospec --preload esm | ||
@@ -402,3 +400,3 @@ ``` | ||
``` | ||
```shell | ||
ospec '**/*.test.js' --ignore 'folder1/**' --preload esm ./my-file.js | ||
@@ -411,3 +409,3 @@ ``` | ||
### Run ospec directly from the command line: | ||
### Run ospec directly from the command line | ||
@@ -430,3 +428,3 @@ ospec comes with an executable named `ospec`. npm auto-installs local binaries to `./node_modules/.bin/`. You can run ospec by running `./node_modules/.bin/ospec` from your project root, but there are more convenient methods to do so that we will soon describe. | ||
``` | ||
```shell | ||
npm install npm-run -g | ||
@@ -437,3 +435,3 @@ ``` | ||
``` | ||
```shell | ||
npm-run ospec | ||
@@ -446,3 +444,3 @@ ``` | ||
``` | ||
```shell | ||
export PATH=./node_modules/.bin:$PATH | ||
@@ -479,3 +477,3 @@ ``` | ||
``` | ||
```shell | ||
o(actualValue).equals(expectedValue) | ||
@@ -488,3 +486,3 @@ ``` | ||
``` | ||
```javascript | ||
o(actualValue).equals(expectedValue)("this is a description for this assertion") | ||
@@ -495,3 +493,3 @@ ``` | ||
``` | ||
```javascript | ||
o(actualValue).equals(expectedValue) `this is a description for this assertion` | ||
@@ -580,3 +578,3 @@ ``` | ||
#### Array<any> o.spy().args | ||
#### Array<any> o.spy().args | ||
@@ -599,3 +597,2 @@ The arguments that were passed to the function in the last time it was called | ||
--- | ||
@@ -616,3 +613,3 @@ | ||
$o("a test", function() { | ||
$o(1).equals(1) | ||
$o(1).equals(1) | ||
}) | ||
@@ -635,7 +632,7 @@ $o.run() | ||
o.run(function(results) { | ||
// results is an array | ||
// results is an array | ||
results.forEach(function(result) { | ||
// ... | ||
}) | ||
results.forEach(function(result) { | ||
// ... | ||
}) | ||
}) | ||
@@ -674,3 +671,3 @@ ``` | ||
o.spec("message", function() { | ||
o(false).equals(true) | ||
o(false).equals(true) | ||
}) | ||
@@ -683,3 +680,3 @@ ``` | ||
o.spec("message", function() { | ||
o(false).equals(true)("Candyland") // result.message === "Candyland\n\nfalse\nshould equal\ntrue" | ||
o(false).equals(true)("Candyland") // result.message === "Candyland\n\nfalse\nshould equal\ntrue" | ||
}) | ||
@@ -697,5 +694,5 @@ ``` | ||
o.spec("testing", function() { | ||
o.spec("rocks", function() { | ||
o(false).equals(true) | ||
}) | ||
o.spec("rocks", function() { | ||
o(false).equals(true) | ||
}) | ||
}) | ||
@@ -708,3 +705,3 @@ ``` | ||
### Definitions: | ||
### Definitions | ||
@@ -715,3 +712,3 @@ - A **test** is the function passed to `o("description", function test() {})`. | ||
- A given test and its associated `beforeEach` and `afterEach` hooks form a **streak**. The `beforeEach` hooks run outermost first, the `afterEach` run outermost last. The hooks are optional, and are tied at test-definition time in the `o.spec()` calls that enclose the test. | ||
- A **spec** is a collection of streaks, specs, one `before` *hook* and one `after` *hook*. Each component is optional. Specs are defined with the `o.spec("spec name", function specDef() {})` calls. | ||
- A **spec** is a collection of streaks, specs, one `before` hook and one `after` hook. Each component is optional. Specs are defined with the `o.spec("spec name", function specDef() {})` calls. | ||
@@ -744,3 +741,3 @@ ### The phases of an ospec run | ||
- A syntax error in a file causes the file to be ignored by the runner. | ||
- A syntax error in a file causes the file to be ignored by the runner. | ||
- At test-definition time: | ||
@@ -753,3 +750,3 @@ - An error thrown at the root of a file will cause subsequent tests and specs to be ignored | ||
- ...prevents further streaks and nested specs in the current spec from running. The `after` *hook* of the spec will run. | ||
- ...if thrown in a `beforeEach` hook of a streak, causes the streak to be hollowed out. Hooks defined in nested scopes and the actual test will not run. The `afterEach` hook corresponding to the one that crashed will run though as will those defined in outer scopes. | ||
- ...if thrown in a `beforeEach` hook of a streak, causes the streak to be hollowed out. Hooks defined in nested scopes and the actual test will not run. However, the `afterEach` hook corresponding to the one that crashed will run, as will those defined in outer scopes. | ||
@@ -764,5 +761,5 @@ For every error thrown, a "bail out" failure is reported. | ||
- Disallow configuration in test-space: | ||
- Disallow ability to pick between API styles (BDD/TDD/Qunit, assert/should/expect, etc) | ||
- Disallow ability to add custom assertion types | ||
- Provide a default simple reporter | ||
- Disallow ability to pick between API styles (BDD/TDD/Qunit, assert/should/expect, etc) | ||
- Disallow ability to add custom assertion types | ||
- Provide a default simple reporter | ||
- Make assertion code terse, readable and self-descriptive | ||
@@ -769,0 +766,0 @@ - Have as few assertion types as possible for a workable usage pattern |
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
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
51439
4
5
685
1
730
1