Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ospec

Package Overview
Dependencies
Maintainers
7
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ospec - npm Package Compare versions

Comparing version 4.1.0 to 4.1.1-and-then-some

18

ospec.js

@@ -223,2 +223,3 @@ "use strict"

}
/* eslint-disable indent */
var nextTickish = hasProcess

@@ -235,2 +236,3 @@ ? process.nextTick

}
/* eslint-enable indent */
o.metadata = function(opts) {

@@ -253,3 +255,2 @@ if (arguments.length === 0) {

stats = {
asyncSuccesses: 0,
bailCount: 0,

@@ -420,4 +421,2 @@ onlyCalledAt: onlyCalledAt

// temporary, for the "old style count" report
if (!threw && task.error != null) {stats.asyncSuccesses++}

@@ -710,3 +709,3 @@ if (!isFinalized) finalize(err, threw, false)

console.warn(
highlight("\n/!\\ WARNING /!\\ o.only() called...\n", colors.term),
highlight("\nWarning: o.only() called...\n", colors.term),
colors.web, ""

@@ -716,3 +715,3 @@ )

console.warn(
highlight("\n/!\\ WARNING /!\\ o.only()\n", colors.term),
highlight("\nWarning: o.only()\n", colors.term),
colors.web, ""

@@ -724,3 +723,3 @@ )

o.report = function (results, stats) {
if (stats == null) stats = {bailCount: 0, asyncSuccesses: 0}
if (stats == null) stats = {bailCount: 0}
var errCount = -stats.bailCount

@@ -747,3 +746,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

@@ -757,8 +755,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))

@@ -765,0 +763,0 @@ }

{
"name": "ospec",
"version": "4.1.0",
"version": "4.1.1-and-then-some",
"description": "Noiseless testing framework",

@@ -22,3 +22,3 @@ "main": "ospec.js",

"scripts": {
"test": "ospec tests/test-*.js",
"test": "node ./bin/ospec tests/test-*.js",
"test-api": "ospec tests/test-api.js",

@@ -29,6 +29,7 @@ "test-cli": "ospec tests/test-cli.js",

"devDependencies": {
"cmd-shim": "4.0.2",
"compose-regexp": "0.4.0",
"eslint": "^6.8.0",
"ospec": "4.0.1"
"ospec": "4.1.1"
}
}

@@ -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)

@@ -24,9 +20,9 @@

- 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

@@ -44,6 +40,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)
})

@@ -56,7 +52,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`
*/
})

@@ -80,8 +76,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)
})
})

@@ -98,10 +94,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)
})
})
})

@@ -122,10 +118,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])
})
})

@@ -140,3 +136,3 @@ ```

function inc() {
count++
count++
}

@@ -148,8 +144,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)
})
})

@@ -165,3 +161,3 @@

o("setTimeout calls callback", function(done) {
setTimeout(done, 10)
setTimeout(done, 10)
})

@@ -174,5 +170,5 @@ ```

o("promise test", function() {
return new Promise(function(resolve) {
setTimeout(resolve, 10)
})
return new Promise(function(resolve) {
setTimeout(resolve, 10)
})
})

@@ -183,3 +179,3 @@ ```

o("promise test", async function() {
await someOtherAsyncFunction()
await someOtherAsyncFunction()
})

@@ -195,17 +191,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() {
// ...
// ...
})

@@ -218,5 +214,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)
})

@@ -229,4 +225,4 @@ ```

o("promise test", function() {
o.timeout(1000)
return someOtherAsyncFunctionThatTakes900ms()
o.timeout(1000)
return someOtherAsyncFunctionThatTakes900ms()
})

@@ -237,4 +233,4 @@ ```

o("promise test", async function() {
o.timeout(1000)
await someOtherAsyncFunctionThatTakes900ms()
o.timeout(1000)
await someOtherAsyncFunctionThatTakes900ms()
})

@@ -251,17 +247,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)
})
})

@@ -278,21 +274,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)
})
})

@@ -307,21 +303,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)
})
})

@@ -335,3 +331,3 @@ ```

o("addition", function() {
o(1 + 1).equals(2)
o(1 + 1).equals(2)
})

@@ -350,3 +346,3 @@

_o("a test", function() {
_o(1).equals(1)
_o(1).equals(1)
})

@@ -359,13 +355,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
```

@@ -380,3 +378,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'

@@ -387,3 +385,3 @@ ```

```
```shell
ospec --ignore 'folder1/**' 'folder2/**'

@@ -394,3 +392,3 @@ ```

```
```shell
ospec --preload esm

@@ -401,3 +399,3 @@ ```

```
```shell
ospec '**/*.test.js' --ignore 'folder1/**' --preload esm ./my-file.js

@@ -410,3 +408,3 @@ ```

### Run ospec directly from the command line:
### Run ospec directly from the command line

@@ -429,3 +427,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

@@ -436,3 +434,3 @@ ```

```
```shell
npm-run ospec

@@ -445,3 +443,3 @@ ```

```
```shell
export PATH=./node_modules/.bin:$PATH

@@ -478,3 +476,3 @@ ```

```
```shell
o(actualValue).equals(expectedValue)

@@ -487,3 +485,3 @@ ```

```
```javascript
o(actualValue).equals(expectedValue)("this is a description for this assertion")

@@ -494,3 +492,3 @@ ```

```
```javascript
o(actualValue).equals(expectedValue) `this is a description for this assertion`

@@ -579,3 +577,3 @@ ```

#### Array<any> o.spy().args
#### Array&lt;any> o.spy().args

@@ -598,3 +596,2 @@ The arguments that were passed to the function in the last time it was called

---

@@ -615,3 +612,3 @@

$o("a test", function() {
$o(1).equals(1)
$o(1).equals(1)
})

@@ -623,3 +620,3 @@ $o.run()

When an error is thrown some tests may be skipped. See the "run time semantics" for a detailed description of the bailout mechanism.
When an error is thrown some tests may be skipped. See the "run time model" for a detailed description of the bailout mechanism.

@@ -635,7 +632,7 @@ ---

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,13 +712,13 @@ - 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.
### The three phases
### The phases of an ospec run
For a given instance, an `ospec` run goes through three phases:
1) test definitions
1) test execution and results accumulation
1) tests definition
1) tests execution and results accumulation
1) results presentation
#### Test definition
#### Tests definition

@@ -732,3 +729,3 @@ This phase is synchronous. `o.spec("spec name", function specDef() {})`, `o("test name", function test() {})` and hooks calls generate a tree of specs and tests.

At test-run time, for each spec, the `before` hook is called if present, then nested specs the streak of each test, in definition order, then the `after` hook, if present.
At test execution time, for each spec, the `before` hook is called if present, then nested specs the streak of each test, in definition order, then the `after` hook, if present.

@@ -745,11 +742,11 @@ Test and hooks may contain assertions, which will populate the `results` array.

- 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:
- An error thrown at the root of a file will cause subsequent tests and specs to be ignored
- An error thrown in a spec definition will cause the spec to be ignored.
- At test-run time:
- At test-execution time:
- An error thrown in the `before` hook will cause the streaks and nested specs to be ignored. The `after` hook will run.
- An error thrown in a task...
- ...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` hookcorresponding 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc