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

mvt

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mvt - npm Package Compare versions

Comparing version 4.2.1 to 5.0.0-beta.1

30

cli.js
#! /usr/bin/env node
'use strict'
import fs from 'fs'
import path from 'path'
import { pathToFileURL } from 'url'
const fs = require('fs')
const path = require('path')
const cwd = process.cwd()
const exts = ['.js', '.mjs']
const args = process.argv.slice(2)
const setup = {}
const flags = {

@@ -19,3 +20,2 @@ '-v': 'verbose',

}
const setup = {}

@@ -80,16 +80,14 @@ const deflagged = args.filter((a) => !(flags[a] && (setup[flags[a]] = true)))

try {
test = require(path.resolve(cwd, 'node_modules', 'mvt'))
test = (await import(path.resolve(cwd, 'node_modules', 'mvt'))).default
} catch (ex) {
test = require('./index')
test = (await import('./index.js')).default
}
const seen = {}
files.forEach((f) => {
for (const f of files) {
if (seen[f]) return
seen[f] = true
try {
test.setup(Object.assign({}, setup, { fileName: path.basename(f) }))
require(f)
} catch (ex) {
const logFailedImport = (ex) => {
console.error(`Unable to require test file ${f}:`)

@@ -99,5 +97,13 @@ console.error(ex)

}
})
try {
test.setup(Object.assign({}, setup, { fileName: path.basename(f) }))
await import(pathToFileURL(f))
} catch (ex) {
logFailedImport(ex)
}
}
}
main().catch(console.error)

8

index.js

@@ -1,9 +0,7 @@

'use strict'
import { test } from './lib/tests.js'
import { _setup } from './lib/state.js'
process.env.NODE_ENV = process.env.NODE_ENV || 'test'
const { test } = require('./lib/tests')
const { _setup } = require('./lib/state')
test.before(_setup)
module.exports = test
export default test

@@ -1,8 +0,8 @@

'use strict'
import { strict } from 'assert'
import { handleError, diffError } from './errors.js'
import { toPrint } from './utility.js'
const { deepStrictEqual, notDeepStrictEqual } = require('assert').strict
const { handleError, diffError } = require('./errors')
const { toPrint } = require('./utility')
const { deepStrictEqual, notDeepStrictEqual } = strict
const assert = (msg, f) => ({
export const assert = (msg, f) => ({
is: is(msg, f),

@@ -28,4 +28,2 @@ not: not(msg, f),

module.exports = { assert }
const wrap = (msg, passFn, err, failing) => {

@@ -32,0 +30,0 @@ let passed = false

@@ -1,10 +0,11 @@

'use strict'
import readline from 'readline'
const readline = require('readline')
const scanner = '\x1b[6n'
const appleTerm = process.env.TERM_PROGRAM === 'Apple_Terminal'
const xterm = process.env.TERM === 'xterm-256color'
const charOffset = appleTerm || xterm ? -1 : 0
const baseCharOffset = appleTerm || xterm ? -1 : 0
const checkChar = (char, expected) => new Promise((resolve, reject) => {
export const charOffset = Math.abs(baseCharOffset)
export const checkChar = (char, expected) => new Promise((resolve, reject) => {
if (!process.stdin.isTTY) return resolve(false)

@@ -37,3 +38,3 @@ let clean = false

const val = +((`${d}` || '').match(/;(\d+)R/) || [])[1]
return cleanup(val === expect || ((val + charOffset) === expect))
return cleanup(val === expect || ((val + baseCharOffset) === expect))
}

@@ -51,3 +52,1 @@

})
module.exports = { checkChar, charOffset: Math.abs(charOffset) }

@@ -1,7 +0,10 @@

'use strict'
import { strict } from 'assert'
import { char, color, toPrint } from './utility.js'
const { deepStrictEqual } = require('assert').strict
const { char, color, toPrint } = require('./utility')
const { deepStrictEqual } = strict
const handleError = (msg, err, noExit) => {
let differ
import('diff').then((mod) => { differ = mod }).catch(() => {})
export const handleError = (msg, err, noExit) => {
process.stderr.write(`${char('fail')} ${msg}\n`)

@@ -21,3 +24,3 @@ err = err || `Failed: ${msg}`

const finalizeError = (error) => {
export const finalizeError = (error) => {
const { noExit } = error.metaMvt || {}

@@ -31,8 +34,6 @@ delete error.metaMvt

const diffError = (a, b, errName = 'Values should be identical') => {
export const diffError = (a, b, errName = 'Values should be identical') => {
let diff
try {
const differ = require('diff')
diff = ''

@@ -58,3 +59,1 @@ differ.diffLines(a, b).forEach(({ added, removed, value }) => {

}
module.exports = { handleError, diffError, finalizeError }

@@ -1,8 +0,6 @@

'use strict'
import readline from 'readline'
import { state } from './state.js'
import { char, color, fmtMs, plural } from './utility.js'
const readline = require('readline')
const { state } = require('./state')
const { char, color, fmtMs, plural } = require('./utility')
const writeNonVerboseCount = () => {
export const writeNonVerboseCount = () => {
const count = ++state.fileTestCount

@@ -14,5 +12,5 @@ readline.cursorTo(process.stdout, 0)

const info = (msg) => process.stdout.write(msg)
export const info = (msg) => process.stdout.write(msg)
const reporter = ({ msg, pass, out, error, mod }) => {
export const reporter = ({ msg, pass, out, error, mod }) => {
const skipNonVerbose = { skip: true, todo: true }

@@ -28,3 +26,3 @@ if (out) {

const summary = (ms) => {
export const summary = (ms) => {
const counts = state.counts

@@ -57,3 +55,1 @@ const result = `${color.green}All tests passed in ${fmtMs(ms)}${color.reset}`

}
module.exports = { reporter, writeNonVerboseCount, info, summary }

@@ -1,10 +0,8 @@

'use strict'
import { state } from './state.js'
import { assert } from './assertions.js'
import { handleError } from './errors.js'
import { reporter, info } from './reporters.js'
import { char, color, fmtMs } from './utility.js'
const { state } = require('./state')
const { assert } = require('./assertions')
const { handleError } = require('./errors')
const { reporter, info } = require('./reporters')
const { char, color, fmtMs } = require('./utility')
const getRunner = (tests) => {
export const getRunner = (tests) => {
const runner = async (t, noExit) => {

@@ -90,3 +88,1 @@ const { msg, fn, failing, benchOpts, fileName: currFile } = t

}
module.exports = { getRunner }

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

'use strict'
import { initCharCheck } from './utility.js'
const { initCharCheck } = require('./utility')
const argv = process.argv

@@ -10,3 +9,3 @@

const state = {
export const state = {
queue: [],

@@ -20,3 +19,3 @@ counts: {},

const _setup = async (opts = {}) => {
export const _setup = async (opts = {}) => {
const setForKey = (k) => opts[k] !== undefined ? !!opts[k] : state[k]

@@ -31,7 +30,5 @@ state.tap = setForKey('tap')

const setup = (opts = {}) => state.queue.push({
export const setup = (opts = {}) => state.queue.push({
fn: () => _setup(opts),
fileName: opts.fileName
})
module.exports = { state, setup, _setup }

@@ -1,11 +0,9 @@

'use strict'
import { state, setup } from './state.js'
import { finalizeError } from './errors.js'
import { getRunner } from './runners.js'
import { assert } from './assertions.js'
import { reporter, summary } from './reporters.js'
import { color, parseMs, char } from './utility.js'
const { state, setup } = require('./state')
const { finalizeError } = require('./errors')
const { getRunner } = require('./runners')
const { assert } = require('./assertions')
const { reporter, summary } = require('./reporters')
const { color, parseMs, char } = require('./utility')
const test = async (msg, fn) => {
export const test = async (msg, fn) => {
if (msg && fn) state.queue.push({ msg, fn, fileName: state.fileName })

@@ -131,2 +129,2 @@

module.exports = { test, failing: test.failing }
export const failing = test.failing

@@ -1,7 +0,6 @@

'use strict'
import { checkChar, charOffset } from './cli-char-supported.js'
const { checkChar, charOffset } = require('./cli-char-supported')
const buf = `${Array(charOffset + 1).join(' ')}`
const color = {
export const color = {
reset: '\u001b[0m',

@@ -16,3 +15,3 @@ green: '\u001b[32m',

let charsChecked = false
const chars = {
export const chars = {
good: { emoji: '✅', plain: `${color.green}[√]` },

@@ -25,3 +24,3 @@ fail: { emoji: '❌', plain: `${color.red}[X]` },

const char = (n) => {
export const char = (n) => {
if (!chars[n].useEmoji) return `${chars[n].plain}${color.reset}`

@@ -31,3 +30,3 @@ return `${chars[n].emoji}${color.reset}${buf}`

const initCharCheck = async () => {
export const initCharCheck = async () => {
if (charsChecked) return

@@ -42,5 +41,5 @@

const toPrint = (s) => typeof s === 'string' ? `'${s}'` : s
export const toPrint = (s) => typeof s === 'string' ? `'${s}'` : s
const parseMs = (str) => {
export const parseMs = (str) => {
const intvls = { s: 1000, m: 60000, h: 3600000, d: 86400000 }

@@ -53,3 +52,3 @@ const num = parseFloat(str)

const fmtMs = (ms) => {
export const fmtMs = (ms) => {
ms = ms || 0

@@ -62,12 +61,2 @@ if (ms < 1000) return `${ms || 0}ms`

const plural = (c, s) => c > 1 ? `${s || 'test'}s` : `${s || 'test'}`
module.exports = {
color,
toPrint,
initCharCheck,
char,
parseMs,
fmtMs,
plural
}
export const plural = (c, s) => c > 1 ? `${s || 'test'}s` : `${s || 'test'}`
{
"name": "mvt",
"version": "4.2.1",
"version": "5.0.0-beta.1",
"description": "Minimum Viable Testing framework",
"type": "module",
"engines": {
"node": ">=8.0.0"
"node": ">=12.20.0"
},

@@ -42,4 +43,4 @@ "main": "index.js",

"devDependencies": {
"ava": "^3.15.0"
"ava": "^4.0.1"
}
}

@@ -1,5 +0,10 @@

# mvt [![NPM version](https://badge.fury.io/js/mvt.svg)](https://npmjs.org/package/mvt) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard) [![Build Status](https://travis-ci.com/doesdev/mvt.svg)](https://travis-ci.com/doesdev/mvt)
# mvt [![NPM version](https://badge.fury.io/js/mvt.svg)](https://npmjs.org/package/mvt) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard) [![Build Status](https://api.travis-ci.com/doesdev/mvt.svg)](https://travis-ci.com/doesdev/mvt)
> Minimum Viable Testing framework
## 5.0.0
Version 5.0.0+ deprecates support for CommonJS, opting to only support ES Modules.
Please use `mvt@4` for CommonJS usage.
## A Minimalist Take on AVA's Approach to Testing

@@ -71,3 +76,3 @@ Because [AVA](https://github.com/avajs/ava) is awesome. Security alerts on dev

```js
const test = require('mvt')
import test from 'mvt'

@@ -74,0 +79,0 @@ test.setup({ verbose: true })

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