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 3.1.0 to 3.2.0

122

index.js
import * as assert from './assert.js'
let ondone
export const done = new Promise((resolve) => {
ondone = resolve
})
function start () {
if (!running) {
running = true
Promise.resolve().then(() => {
const hasOnly = tests.some((test) => test.only)
tests.forEach((test) => {
test.shouldRun = true
if (test.skip) {
test.shouldRun = false
} else if (hasOnly) {
test.shouldRun = test.only
}
})
dequeue()
})
}
}
function Test(o) {
Object.assign(this, o)
this.assertion = []
}
Test.prototype.time = null
Test.prototype.run = async function run () {

@@ -38,7 +12,12 @@ let from = this.startTime = performance.now()

}
Object.assign(Test.prototype, assert)
Object.assign(Test.prototype, {
skip: false,
todo: false,
only: false,
fn: null
}, assert)
export default function test (name, fn) {
if (!fn) return test.todo(name)
let t = new Test({ name, fn, skip: false, only: false, shouldRun: false, assert: [] })
let t = new Test({ name, fn })
tests.push(t)

@@ -48,11 +27,10 @@ start()

}
test.todo = function (name, fn) {
let t = new Test({ name, fn, skip: true, todo: true, only: false, shouldRun: null, assert: [] })
let t = new Test({ name, fn, todo: true })
tests.push(t)
start()
return t
}
test.skip = function (name, fn) {
let t = new Test({ name, fn, skip: true, only: false, shouldRun: null, assert: [] })
let t = new Test({ name, fn, skip: true })
tests.push(t)

@@ -62,5 +40,4 @@ start()

}
test.only = function (name, fn) {
let t = new Test({ name, fn, skip: false, only: true, shouldRun: null, assert: [] })
let t = new Test({ name, fn, only: true })
tests.push(t)

@@ -71,5 +48,3 @@ start()

let testIndex = 0
let assertIndex = 0
let running = false

@@ -88,7 +63,7 @@ const tests = []

if (ok) {
current.assert.push({ idx: assertIndex, msg })
current.assertion.push({ idx: assertIndex, msg })
console.log(`%c ✔ ${assertIndex} — ${msg}`, 'color: #229944')
passed += 1
} else {
current.assert.push({ idx: assertIndex, msg, info, error: new Error() })
current.assertion.push({ idx: assertIndex, msg, info, error: new Error() })
failed += 1

@@ -99,18 +74,38 @@ console.assert(false, `${assertIndex} — ${msg}`, info, (new Error()))

let ondone, hasOnly = false, running = false
function start() {
if (!running) {
running = true
Promise.resolve().then(() => {
hasOnly = tests.some(test => test.only)
dequeue()
})
}
}
async function dequeue () {
const test = tests[testIndex++]
if (tests.length) {
const test = tests.shift()
if (test) {
if (!test.shouldRun) {
if (test.todo) {
console.log(`# todo ${test.name}`)
}
else if (test.skip) {
console.log(`%c# skip ${test.name}`, 'color: #ddd')
skipped += 1
}
dequeue()
return
if (hasOnly && !test.only) {
// in only-run - ignore tests
skipped += 1
return dequeue()
}
if (test.skip) {
console.log(`%c# skip ${test.name}`, 'color: #ddd')
skipped += 1
return dequeue()
}
if (test.todo) {
console.log(`# todo ${test.name}`)
return dequeue()
}
try {

@@ -126,17 +121,20 @@ current = test

dequeue()
return dequeue()
}
// summarise
else {
const total = passed + failed + skipped
console.log(`\n1..${total}`)
console.log(`# tests ${total}`)
if (passed) console.log(`# pass ${passed}`)
if (failed) console.log(`# fail ${failed}`)
if (skipped) console.log(`# skip ${skipped}`)
const total = passed + failed + skipped
console.log(`---\n# tests ${total}`)
if (hasOnly) console.log(`# only ${total - skipped}`)
if (passed) console.log(`# pass ${passed}`)
if (failed) console.log(`# fail ${failed}`)
if (skipped) console.log(`# skip ${skipped}`)
ondone()
if (isNode) process.exit(failed ? 1 : 0)
}
ondone()
if (isNode) process.exit(failed ? 1 : 0)
}
export const done = new Promise((resolve) => {
ondone = resolve
})
{
"name": "tst",
"description": "Testing tool",
"version": "3.1.0",
"version": "3.2.0",
"repository": "dy/tst",

@@ -6,0 +6,0 @@ "author": "Dmitry Yv",

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