New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More โ†’
Socket
Sign inDemoInstall
Socket

tst

Package Overview
Dependencies
Maintainers
3
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tst - npm Package Compare versions

Comparing version 5.3.3 to 6.0.0

76

assert.js

@@ -1,3 +0,1 @@

import deq from 'dequal'
export function fail(msg) {

@@ -18,53 +16,2 @@ this.log(false, 'fail', msg)

export function notOk(value, msg = 'should be falsy') {
this.log(!value, 'notOk', msg, {
actual: value,
expected: false
})
}
export function equal(a, b, msg = 'should equal') {
this.log(Object.is(a, b), 'equal', msg, {
actual: a,
expected: b
})
}
export function notEqual(a, b, msg = 'should not equal') {
this.log(!Object.is(a, b), 'notEqual', msg, {
actual: a,
expected: b
})
}
export function equalAny(a, list, msg = 'should equal any') {
this.log(list.some(b => Object.is(a, b)), 'equalAny', msg, {
actual: a,
expected: new (class Any extends Array {})(...list)
})
}
export function deepEqual(a, b, msg = 'should deep equal') {
this.log(deq(a, b), 'deepEqual', msg, {
actual: isPrimitive(a) ? a : a.slice ? a.slice() : Object.assign({}, a),
expected: isPrimitive(b) ? b : b.slice ? b.slice() : Object.assign({}, b)
})
}
export function notDeepEqual(a, b, msg = 'should deep equal') {
this.log(!deq(a, b), 'notDeepEqual', msg, {
actual: isPrimitive(a) ? a : a.slice ? a.slice() : Object.assign({}, a),
expected: isPrimitive(b) ? b : b.slice ? b.slice() : Object.assign({}, b)
})
}
export function deepEqualAny(a, list, msg = 'should deep equal any') {
this.log(list.some(b => deq(a, b)), 'deepEqualAny', msg, {
actual: isPrimitive(a) ? a : a.slice ? a.slice() : Object.assign({}, a),
expected: new (class Any extends Array {})(...list.map(b =>
isPrimitive(b) ? b : b.slice ? b.slice() : Object.assign({}, b)
))
})
}
export function is(a, b, msg = 'should be the same') {

@@ -84,6 +31,6 @@ this.log(isPrimitive(a) || isPrimitive(b) ? Object.is(a, b) : deq(a, b), 'is', msg, {

export function oneOf(a, list, msg = 'should be one of') {
export function any(a, list, msg = 'should be one of') {
this.log(list.some(b =>
isPrimitive(a) || isPrimitive(b) ? Object.is(a, b) : deq(a, b)
), 'oneOf', msg, {
), 'any', msg, {
actual: isPrimitive(a) ? a : a.slice ? a.slice() : Object.assign({}, a),

@@ -95,3 +42,2 @@ expected: new (class Any extends Array { })(...list.map(b =>

}
export const any = oneOf

@@ -134,2 +80,16 @@ export function almost (a, b, eps, msg = 'should almost equal') {

function deq (a, b) {
if (a === b) return true
if (a && b) {
if (a.constructor === b.constructor) {
if (a.constructor === RegExp) return a.toString() === b.toString()
if (a.constructor === Date) return a.getTime() === b.getTime()
if (a.constructor === Array) return a.length === b.length && a.every((a, i) => a === b[i])
if (a.constructor === Object) return Object.keys(a).length === Object.keys(b).length && Object.keys(a).every(key => a[key] === b[key])
}
if (a[Symbol.iterator] && b[Symbol.iterator]) return deq([...a], [...b])
}
return a !== b && b !== a
}
function isPrimitive(val) {

@@ -155,5 +115,3 @@ if (typeof val === 'object') {

if (d <= eps) {
return true
}
if (d <= eps) return true

@@ -160,0 +118,0 @@ return a === b

import * as assert from './assert.js'
const isNode = typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]'
const hasImport = typeof require === 'undefined'
const GREEN = '\u001b[32m', RED = '\u001b[31m', YELLOW = '\u001b[33m', RESET = '\u001b[0m', CYAN = '\u001b[36m'

@@ -43,8 +42,2 @@

}
test.require = function (name, fn) {
return createTest({ name, fn, skip: hasImport, tag: 'require' })
}
test.import = function (name, fn) {
return createTest({ name, fn, skip: !hasImport, tag: 'import' })
}

@@ -113,2 +106,4 @@

result = await test.fn(test)
// let all planned errors to log
await new Promise(r => setTimeout(r))
}

@@ -115,0 +110,0 @@ catch (e) {

{
"name": "tst",
"description": "Tape-compatible test runner",
"version": "5.3.3",
"description": "Tests without efforts",
"version": "6.0.0",
"repository": "dy/tst",
"author": "Dmitry Yv",
"author": "Dmitry Iv.",
"main": "index.js",

@@ -11,4 +11,8 @@ "module": "index.js",

"license": "MIT",
"files": [
"index.js",
"assert.js"
],
"scripts": {
"test": "node -r esm test.js",
"test": "node test.js",
"start": "es-dev-server --node-resolve --dedupe"

@@ -18,8 +22,4 @@ },

"es-dev-server": "^1.32.0",
"esm": "^3.2.25"
},
"dependencies": {
"dequal": "^1.0.0",
"wait-please": "^2.0.1"
}
}
# tst
* tape-compatible
Tests without _e_fforts.
## Gems
* tape-like
* async functions support
* `t.todo`, `t.fixme` for broken / unfinished tests
* `t.node`, `t.browser`, `t.require`, `t.import` - environment conditional tests
* `t.demo` - demo-run (can fail)
* `t.is` - assert with `t.equal` for primitives and `t.deepEqual` for other
* `t.oneOf(item, list, msg)` - assert optional results
* `t.almost(a, b, eps, msg)` - assert approx value/array
* `t.same(listA, listB, msg)` - assert same members
* `console.group` in browser
* inspectable errors

@@ -18,6 +14,19 @@ * correct stacktrace with sourcemaps

* multiple `only` tests
* run by `idle`
* start by `idle` event
* ES export
<!-- same -->
* `test.todo`, `test.fixme` for broken / unfinished tests
* `test.node`, `test.browser` - environment conditional tests
* `test.demo` - demo-run (can fail)
* `console.group` in browser
## Assertions
* `t.ok(a, b, msg?)` โˆ’ generic truthfulness assert
* `t.is(a, b, msg?)` โˆ’ assert with `equal` for primitives and `deepEqual` for other
* `t.any(a, [a, b, c], msg?)` โˆ’ assert with optional results
* `t.almost(a, b, eps, msg?)` โˆ’ assert approximate value/array
* `t.same(listA, listB, msg?)` โˆ’ assert same members
* `t.throws(fn, msg?)` โˆ’ fn must throw
* `t.pass(msg)`, `t.fail(msf)` โˆ’ pass or fail the whole test.
## Install

@@ -33,4 +42,2 @@

## Asserts
## Use

@@ -67,7 +74,11 @@

### Neighbor art
Creates output in console:
![preview](./preview.png)
### Neighbors
* [tape-modern](https://ghub.io/tape-modern)
* [@goto-bus-stop/tape-modern](https://github.com/goto-bus-stop/tape-modern#readme)
<p align="right">HK</p>
<p align="right">๐Ÿ•‰๏ธ</p>
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