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

bron

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bron - npm Package Compare versions

Comparing version 1.1.1 to 2.0.0

6

bron.js
#!/usr/bin/env node
const { EOL } = require('os');
const { existsSync } = require('fs');
const { run } = require('.');
import { EOL } from 'os';
import { existsSync } from 'fs';
import { run } from '.';

@@ -7,0 +7,0 @@ const args = process.argv.slice(2);

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

const { types } = require('util');
const { resolve } = require('path');
import { types } from 'util';
import { resolve } from 'path';
const isPromise = types && types.isPromise ? types.isPromise : p => p && typeof p.then === 'function';
let [tests, only] = [[], []];
let [tests, _only] = [[], []];
let [passed, failed, skipped] = [0, 0, 0];

@@ -51,18 +51,22 @@

module.exports = (title, testFn) => tests.push([title, testFn]);
module.exports.skip = () => skipped++;
module.exports.only = (title, testFn) => only.push([title, testFn]);
const test = (title, testFn) => tests.push([title, testFn]);
test.skip = () => skipped++;
test.only = (title, testFn) => _only.push([title, testFn]);
module.exports.run = async ({ files, isSerial, timeout }) => {
[tests, only] = [[], [], []];
export default test;
export const run = async ({ files, isSerial, timeout }) => {
[tests, _only] = [[], [], []];
[passed, failed, skipped] = [0, 0, 0];
files.forEach(file => require(resolve(file)));
for (const file of files) {
await import(resolve(file));
}
const results = await execute({ tests: only.length ? only : tests, isSerial, timeout });
const results = await execute({ tests: _only.length ? _only : tests, isSerial, timeout });
await Promise.all(results).catch(() => {});
const total = tests.length + only.length + skipped;
const total = tests.length + _only.length + skipped;
return { total, failed, passed };
};
{
"name": "bron",
"version": "1.1.1",
"version": "2.0.0",
"description": "Tiny test runner",
"main": "index.js",
"exports": "./index.js",
"type": "module",
"bin": "bron.js",

@@ -37,13 +38,13 @@ "scripts": {

"engines": {
"node": ">=8"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"license": "MIT",
"devDependencies": {
"eslint": "^6.1.0",
"eslint-config-prettier": "^6.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-prettier": "^3.1.0",
"prettier": "^1.18.2",
"release-it": "^12.2.2",
"sinon": "^7.3.2"
"eslint": "^7.31.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-prettier": "^3.4.0",
"prettier": "^2.3.2",
"release-it": "^14.10.1",
"sinon": "^11.1.1"
},

@@ -50,0 +51,0 @@ "release-it": {

@@ -11,3 +11,4 @@ # bron

- Timeouts (default: 15s)
- Requires Node.js v8+ (Node.js v12 has better validations and error messages)
- Requires Node.js v12.20+
- Written in/published as pure ES Modules

@@ -20,3 +21,3 @@ [![Build Status](https://travis-ci.org/webpro/bron.svg?branch=master)](https://travis-ci.org/webpro/bron)

Often for small projects, test suites consist of some wrapped assertions in `test` or `it` functions. Node.js has a fine
`assert` module built-in, while exception output is prettier in Node v12. Last but not least, if any test fails, the
`assert` module built-in, while exception output is pretty since Node v12. Last but not least, if any test fails, the
process should exit with a non-zero code so that CI/CD environments can act accordingly.

@@ -69,4 +70,4 @@

```js
const test = require('bron');
const assert = require('assert').strict;
import test from 'bron';
import assert from 'assert'.strict;

@@ -73,0 +74,0 @@ const add = (x, y) => x + y;

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

const assert = require('assert');
const { add, addAsync } = require('./helpers');
const test = require('..');
import assert from 'assert';
import { add, addAsync } from './helpers.js';
import test from '../index.js';

@@ -5,0 +5,0 @@ test('should pass', () => {

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

const add = (x, y) => x + y;
export const add = (x, y) => x + y;
const addAsync = (x, y) =>
export const addAsync = (x, y) =>
typeof x === 'number' && typeof y === 'number' ? Promise.resolve(x + y) : Promise.reject(new Error('No can do!'));
const wait = milliseconds => new Promise(resolve => setTimeout(resolve, milliseconds));
module.exports = { add, addAsync, wait };
export const wait = milliseconds => new Promise(resolve => setTimeout(resolve, milliseconds));

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

const { EOL } = require('os');
const assert = require('assert');
const sinon = require('sinon');
const { run } = require('..');
import { EOL } from 'os';
import assert from 'assert';
import sinon from 'sinon';
import { run } from '../index.js';

@@ -16,7 +16,7 @@ const logStub = sinon.stub(console, 'log');

assert.deepEqual(output, ['✔ should pass first', '✔ should pass in-between', '✔ should pass last']);
assert.deepStrictEqual(output, ['✔ should pass first', '✔ should pass in-between', '✔ should pass last']);
assert.equal(total, 3);
assert.equal(failed, 0);
assert.equal(passed, 3);
assert.deepStrictEqual(total, 3);
assert.deepStrictEqual(failed, 0);
assert.deepStrictEqual(passed, 3);

@@ -34,3 +34,3 @@ console.info(output.join(EOL));

assert.deepEqual(output, [
assert.deepStrictEqual(output, [
'✔ should pass',

@@ -47,5 +47,5 @@ '✖ should fail',

assert.equal(total, 9);
assert.equal(failed, 1);
assert.equal(passed, 8);
assert.deepStrictEqual(total, 9);
assert.deepStrictEqual(failed, 1);
assert.deepStrictEqual(passed, 8);

@@ -64,3 +64,7 @@ console.info(output.join(EOL));

assert.deepEqual(output, ['✔ should pass', '✖ should fail', '✖ should fail with returned rejected promise']);
assert.deepStrictEqual(output, [
'✔ should pass',
'✖ should fail',
'✖ should fail with returned rejected promise'
]);

@@ -74,5 +78,5 @@ assert(errorArgs[0] instanceof assert.AssertionError);

assert.equal(total, 3);
assert.equal(failed, 2);
assert.equal(passed, 1);
assert.deepStrictEqual(total, 3);
assert.deepStrictEqual(failed, 2);
assert.deepStrictEqual(passed, 1);

@@ -89,7 +93,7 @@ console.info(output.join(EOL));

assert.deepEqual(output, ['✔ should not be skipped', '✔ should not be skipped']);
assert.deepStrictEqual(output, ['✔ should not be skipped', '✔ should not be skipped']);
assert.equal(total, 4);
assert.equal(failed, 0);
assert.equal(passed, 2);
assert.deepStrictEqual(total, 4);
assert.deepStrictEqual(failed, 0);
assert.deepStrictEqual(passed, 2);

@@ -106,7 +110,7 @@ console.info(output.join(EOL));

assert.deepEqual(output, ['✔ should not be skipped', '✔ should not be skipped']);
assert.deepStrictEqual(output, ['✔ should not be skipped', '✔ should not be skipped']);
assert.equal(total, 4);
assert.equal(failed, 0);
assert.equal(passed, 2);
assert.deepStrictEqual(total, 4);
assert.deepStrictEqual(failed, 0);
assert.deepStrictEqual(passed, 2);

@@ -123,3 +127,3 @@ console.info(output.join(EOL));

assert.deepEqual(output, [
assert.deepStrictEqual(output, [
'✔ should not time out',

@@ -132,5 +136,5 @@ '✔ should not time out (1ms)',

assert.equal(total, 5);
assert.equal(failed, 2);
assert.equal(passed, 3);
assert.deepStrictEqual(total, 5);
assert.deepStrictEqual(failed, 2);
assert.deepStrictEqual(passed, 3);

@@ -137,0 +141,0 @@ console.info(output.join(EOL));

@@ -1,2 +0,2 @@

const test = require('..');
import test from '../index.js';

@@ -3,0 +3,0 @@ test.only('should not be skipped', () => {});

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

const assert = require('assert');
const { wait } = require('./helpers');
const test = require('..');
import assert from 'assert';
import test from '../index.js';
import { wait } from './helpers.js';

@@ -5,0 +5,0 @@ test('should pass last', async () => {

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

const assert = require('assert');
const { add, addAsync, wait } = require('./helpers');
const test = require('..');
import assert from 'assert';
import { add, addAsync, wait } from './helpers.js';
import test from '../index.js';

@@ -5,0 +5,0 @@ test('should pass', () => {

@@ -1,2 +0,2 @@

const test = require('..');
import test from '../index.js';

@@ -3,0 +3,0 @@ test('should not be skipped', () => {});

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

const assert = require('assert');
const { wait } = require('./helpers');
const test = require('..');
import assert from 'assert';
import { wait } from './helpers.js';
import test from '../index.js';

@@ -5,0 +5,0 @@ test('should not time out', async () => {

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