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

uvu

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uvu - npm Package Compare versions

Comparing version 0.4.0-next.4 to 0.4.0

19

bin.js

@@ -6,7 +6,2 @@ #!/usr/bin/env node

const hasImport = (() => {
try { new Function('import').call(0) }
catch (err) { return !/unexpected/i.test(err.message) }
})();
sade('uvu [dir] [pattern]')

@@ -25,7 +20,11 @@ .version(pkg.version)

if (hasImport) {
await import('uvu/run').then(m => m.default(suites, opts));
} else {
await require('uvu/run')(suites, opts);
}
// TODO: mjs vs js file
globalThis.UVU_DEFER = 1;
suites.forEach((x, idx) => {
globalThis.UVU_INDEX = idx;
QUEUE.push([x.name]);
require(x.file); // auto-add to queue
});
await exec(opts.bail);
} catch (err) {

@@ -32,0 +31,0 @@ console.error(err.stack || err.message);

const kleur = require('kleur');
const differ = require('diff');
const diff = require('diff');
// Native ESM workaround, until resolved at source
// @see https://github.com/kpdecker/jsdiff/issues/292
const diff = differ.default || differ;
const colors = {

@@ -96,3 +92,3 @@ '--': kleur.red,

// no length offsets
} else if (tmp.removed) {
} else if (tmp.removed && arr[i + 1]) {
let del = tmp.count - arr[i + 1].count;

@@ -99,0 +95,0 @@ if (del == 0) {

@@ -59,25 +59,4 @@ const kleur = require('kleur');

function toProxy(cache) {
return {
get(obj, key) {
let tmp = obj[key];
if (!tmp || typeof tmp !== 'object') return tmp;
let nxt = cache.get(tmp);
if (nxt) return nxt;
nxt = new Proxy(tmp, this);
cache.set(tmp, nxt);
return nxt;
},
set() {
write('\n' + kleur.yellow('[WARN]') + ' Cannot modify context within tests!\n');
return true;
}
}
}
async function runner(ctx, name) {
let { only, tests, before, after, bEach, aEach, state } = ctx;
let reader = Proxy.revocable(state, toProxy(new Map));
let hook, test, arr = only.length ? only : tests;

@@ -91,5 +70,6 @@ let num=0, errors='', total=arr.length;

for (test of arr) {
state.__test__ = test.name;
try {
for (hook of bEach) await hook(state);
await test.handler(reader.proxy);
await test.handler(state);
for (hook of aEach) await hook(state);

@@ -106,3 +86,3 @@ write(PASS);

} finally {
reader.revoke();
state.__test__ = '';
for (hook of after) await hook(state);

@@ -117,2 +97,4 @@ let msg = ` (${num} / ${total})\n`;

function setup(ctx, name = '') {
ctx.state.__test__ = '';
ctx.state.__suite__ = name;
const test = into(ctx, 'tests');

@@ -119,0 +101,0 @@ test.before = hook(ctx, 'before');

declare namespace uvu {
type Callback<T> = (context: T) => Promise<void> | void;
type Crumbs = { __suite__: string; __test__: string };
type Callback<T> = (context: T & Crumbs) => Promise<void> | void;

@@ -20,5 +21,8 @@ interface Hook<T> {

type Context = Record<string, any>;
export type Test<T=Context> = uvu.Test<T>;
export type Callback<T=Context> = uvu.Callback<T>;
export const test: uvu.Test<Context>;
export type Callback<T=Context> = uvu.Callback<T>;
export function suite<T=Context>(title?: string, suite?: T): uvu.Test<T>;
export function suite<T=Context>(title?: string, context?: T): uvu.Test<T>;
export function exec(bail?: boolean): Promise<void>;
{
"name": "uvu",
"version": "0.4.0-next.4",
"version": "0.4.0",
"repository": "lukeed/uvu",

@@ -29,6 +29,2 @@ "description": "uvu is an extremely fast and lightweight test runner for Node.js and the browser",

"import": "./parse/index.mjs"
},
"./run": {
"require": "./run/index.js",
"import": "./run/index.mjs"
}

@@ -42,4 +38,3 @@ },

"diff",
"dist",
"run"
"dist"
],

@@ -46,0 +41,0 @@ "modes": {

Sorry, the diff of this file is not supported yet

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