Socket
Socket
Sign inDemoInstall

ospec

Package Overview
Dependencies
Maintainers
4
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 3.0.1 to 3.1.0

esm.js

61

change-log.md

@@ -1,21 +0,34 @@

# Change Log for ospec
# Change log for ospec
- [Upcoming](#upcoming)
- [3.1.0](#310)
- [3.0.1](#301)
- [3.0.0](#300)
- [2.1.0](#210)
- [2.0.0](#200)
- [1.4.1](#141)
- [1.4.0](#140)
- [1.3 and earlier](#13-and-earlier)
## Upcoming...
_2018-xx-yy_
### Upcoming...
### 3.1.0
- ospec: Test results now include `.message` and `.context` regardless of whether the test passed or failed. (#2227 @robertakarobin)
<!-- Add new lines here. Version number will be decided later -->
- Add `spy.calls` array property to get the `this` and `arguments` values for any arbitrary call. (#2221 @isiahmeadows)
- Added `.throws` and `.notThrows` assertions to ospec. (#2255 @robertakarobin)
- Update `glob` dependency.
## 3.0.1
_2018-06-30_
### 3.0.1
### Bug fix
#### Bug fix
- Move `glob` from `devDependencies` to `dependencies`, fix the test runner ([#2186](https://github.com/MithrilJS/mithril.js/pull/2186) [@porsager](https://github.com/porsager)
## 3.0.0
_2018-06-20_
### Breaking
### 3.0.0
#### Breaking
- Better input checking to prevent misuses of the library. Misues of the library will now throw errors, rather than report failures. This may uncover bugs in your test suites. Since it is potentially a disruptive update this change triggers a semver major bump. ([#2167](https://github.com/MithrilJS/mithril.js/pull/2167))
- Change the reserved character for hooks and test suite meta-information from `"__"` to `"\x01"`. Tests whose name start with `"\0x01"` will be rejected ([#2167](https://github.com/MithrilJS/mithril.js/pull/2167))
### Features
#### Features
- Give async timeout a stack trace that points to the problematic test ([#2154](https://github.com/MithrilJS/mithril.js/pull/2154) [@gilbert](github.com/gilbert), [#2167](https://github.com/MithrilJS/mithril.js/pull/2167))

@@ -26,3 +39,3 @@ - deprecate the `timeout` parameter in async tests in favour of `o.timeout()` for setting the timeout delay. The `timeout` parameter still works for v3, and will be removed in v4 ([#2167](https://github.com/MithrilJS/mithril.js/pull/2167))

### Bug fixes
#### Bug fixes
- Detect duplicate calls to `done()` properly [#2162](https://github.com/MithrilJS/mithril.js/issues/2162) ([#2167](https://github.com/MithrilJS/mithril.js/pull/2167))

@@ -35,14 +48,14 @@ - Don't try to report internal errors as assertion failures, throw them instead ([#2167](https://github.com/MithrilJS/mithril.js/pull/2167))

## 2.1.0
_2018-05-25_
### Features
### 2.1.0
#### Features
- 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
#### 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
_2018-05-09_
### 2.0.0
- Added `--require` feature to the ospec executable ([#2144](https://github.com/MithrilJS/mithril.js/pull/2144), [@gilbert](https://github.com/gilbert))

@@ -61,4 +74,4 @@ - In Node.js, ospec only uses colors when the output is sent to a terminal ([#2143](https://github.com/MithrilJS/mithril.js/pull/2143))

## 1.4.1
_2018-05-03_
### 1.4.1
- Identical to v1.4.0, but with UNIX-style line endings so that BASH is happy.

@@ -68,4 +81,4 @@

## 1.4.0
_2017-12-01_
### 1.4.0
- Added support for async functions and promises in tests ([#1928](https://github.com/MithrilJS/mithril.js/pull/1928), [@StephanHoyer](https://github.com/StephanHoyer))

@@ -77,8 +90,6 @@ - Error handling for async tests with `done` callbacks supports error as first argument ([#1928](https://github.com/MithrilJS/mithril.js/pull/1928))

## 1.3 and earlier
### 1.3 and earlier
- Log using util.inspect to show object content instead of "[object Object]" ([#1661](https://github.com/MithrilJS/mithril.js/issues/1661), [@porsager](https://github.com/porsager))
- Shell command: Ignore hidden directories and files ([#1855](https://github.com/MithrilJS/mithril.js/pull/1855) [@pdfernhout)](https://github.com/pdfernhout))
- Library: Add the possibility to name new test suites ([#1529](https://github.com/MithrilJS/mithril.js/pull/1529))

@@ -12,2 +12,5 @@ "use strict"

try {throw new Error} catch (e) {
var ospecFileName = e.stack && (/[\/\\](.*?):\d+:\d+/).test(e.stack) ? e.stack.match(/[\/\\](.*?):\d+:\d+/)[1] : null
}
function o(subject, predicate) {

@@ -53,2 +56,3 @@ if (predicate === undefined) {

spy.args = [].slice.call(arguments)
spy.calls.push({this: this, args: spy.args})
spy.callCount++

@@ -64,2 +68,3 @@

spy.args = []
spy.calls = []
spy.callCount = 0

@@ -221,2 +226,4 @@ return spy

define("notDeepEquals", "should not deep equal", function(a, b) {return !deepEqual(a, b)})
define("throws", "should throw a", throws)
define("notThrows", "should not throw a", function(a, b) {return !throws(a, b)})

@@ -262,2 +269,14 @@ function isArguments(a) {

}
function throws(a, b){
try{
a()
}catch(e){
if(typeof b === "string"){
return (e.message === b)
}else{
return (e instanceof b)
}
}
return false
}

@@ -276,12 +295,16 @@ function isRunning() {return results != null}

Assert.prototype[name] = function assert(value) {
if (compare(this.value, value)) succeed(this)
else fail(this, serialize(this.value) + "\n " + verb + "\n" + serialize(value))
var self = this
return function(message) {
if (!self.pass) self.message = message + "\n\n" + self.message
}
var message = serialize(self.value) + "\n " + verb + "\n" + serialize(value)
if (compare(self.value, value)){
succeed(self, message)
return function(message) {
if (!self.pass) self.message = message + "\n\n" + self.message
}
}else fail(self, message)
}
}
function succeed(assertion) {
function succeed(assertion, message) {
results[assertion.i].pass = true
results[assertion.i].context = subjects.join(" > ")
results[assertion.i].message = message
}

@@ -288,0 +311,0 @@ function fail(assertion, message, error) {

{
"name": "ospec",
"version": "3.0.1",
"version": "3.1.0",
"description": "Noiseless testing framework",
"main": "ospec.js",
"module": "ospec.mjs",
"directories": {

@@ -10,3 +11,3 @@ "test": "tests"

"keywords": [ "testing" ],
"author": "Leo Horie <lhorie@hotmail.com>",
"author": "Leo Horie <leohorie@hotmail.com>",
"license": "MIT",

@@ -16,6 +17,9 @@ "bin": {

},
"scripts": {
"prepublishOnly": "node esm.js"
},
"repository": "MithrilJS/mithril.js",
"dependencies": {
"glob": "^7.1.2"
"glob": "^7.1.3"
}
}

@@ -114,2 +114,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)

o(spy.args[0]).equals(1)
o(spy.calls[0]).deepEquals([1])
})

@@ -386,4 +387,6 @@ })

If you're using an older NPM version, you can use [`npm-run`](https://www.npmjs.com/package/npm-run) which enables one to run the binaries of locally installed packages as npx would.
If you're using a recent version of npm (v5+), you can use run `npx ospec` from your project folder.
Otherwise, to work around this limitation, you can use [`npm-run`](https://www.npmjs.com/package/npm-run) which enables one to run the binaries of locally installed packages.
```

@@ -431,3 +434,3 @@ npm install npm-run -g

Starts an assertion. There are four types of assertion: `equals`, `notEquals`, `deepEquals` and `notDeepEquals`.
Starts an assertion. There are six types of assertion: `equals`, `notEquals`, `deepEquals`, `notDeepEquals`, `throws`, `notThrows`.

@@ -470,2 +473,18 @@ Assertions have this form:

#### Function(String description) o(Function fn).throws(Object constructor)
Asserts that a function throws an instance of the provided constructo
#### Function(String description) o(Function fn).throws(String message)
Asserts that a function throws an Error with the provided message
#### Function(String description) o(Function fn).notThrows(Object constructor)
Asserts that a function does not throw an instance of the provided constructor
#### Function(String description) o(Function fn).notThrows(String message)
Asserts that a function does not throw an Error with the provided message
---

@@ -621,3 +640,3 @@

In case of failure, a `>`-separated string showing the structure of the test specification.
A `>`-separated string showing the structure of the test specification.
In the below example, `result.context` would be `testing > rocks`.

@@ -624,0 +643,0 @@

@@ -92,2 +92,4 @@ "use strict"

o("error" in results[0] && "pass" in results[0]).equals(true)("error and pass keys present in failing result")
o("message" in results[0] && "context" in results[0]).equals(true)("message and context keys present in failing result")
o("message" in results[1] && "context" in results[1]).equals(true)("message and context keys present in passing result")
o(results[0].pass).equals(false)("Test meant to fail has failed")

@@ -138,3 +140,2 @@ o(results[1].pass).equals(true)("Test meant to pass has passed")

o.spec("ospec", function() {

@@ -169,3 +170,11 @@ o.spec("sync", function() {

o([{a: 1, b: 2}, {c: 3}]).deepEquals([{a: 1, b: 2}, {c: 3}])
o(function(){throw new Error()}).throws(Error)
o(function(){"ayy".foo()}).throws(TypeError)
o(function(){Math.PI.toFixed(Math.pow(10,20))}).throws(RangeError)
o(function(){decodeURIComponent("%")}).throws(URIError)
o(function(){"ayy".foo()}).notThrows(SyntaxError)
o(function(){throw new Error("foo")}).throws("foo")
o(function(){throw new Error("foo")}).notThrows("bar")
var undef1 = {undef: void 0}

@@ -212,2 +221,4 @@ var undef2 = {UNDEF: void 0}

o(spy.args[0]).equals(1)
o(spy.calls.length).equals(1)
o(spy.calls[0]).deepEquals({this: undefined, args: [1]})
})

@@ -230,2 +241,4 @@ o("spy wrapping", function() {

o(spy.args[0]).deepEquals({children: children})
o(spy.calls.length).equals(1)
o(spy.calls[0]).deepEquals({this: state, args: [{children: children}]})
o(state).deepEquals({drawn: true})

@@ -469,3 +482,3 @@ o(output).deepEquals({tag: "div", children: children})

oo(true).equals(true)
return {then: function() {}}

@@ -499,6 +512,6 @@ })

})
oo("", function() {
oo(true).equals(true)
return {then: function() {}}

@@ -673,3 +686,3 @@ })

*/ /**/ //ho
done /*hey
done /*hey
*/ /**/ //huuu

@@ -676,0 +689,0 @@ , timeout

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