Socket
Socket
Sign inDemoInstall

jest-each

Package Overview
Dependencies
5
Maintainers
6
Versions
143
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 29.1.2 to 29.2.0

46

build/bind.js

@@ -7,23 +7,15 @@ 'use strict';

exports.default = bind;
function _jestUtil() {
const data = require('jest-util');
_jestUtil = function () {
return data;
};
return data;
}
var _array = _interopRequireDefault(require('./table/array'));
var _template = _interopRequireDefault(require('./table/template'));
var _validation = require('./validation');
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
/**

@@ -36,7 +28,8 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

*/
function bind(cb, supportsDone = true) {
return (table, ...taggedTemplateData) =>
function eachBind(title, test, timeout) {
function bind(cb, supportsDone = true, needsEachError = false) {
const bindWrap = (table, ...taggedTemplateData) => {
const error = new (_jestUtil().ErrorWithStack)(undefined, bindWrap);
return function eachBind(title, test, timeout) {
title = (0, _jestUtil().convertDescriptorToString)(title);
try {

@@ -47,19 +40,27 @@ const tests = isArrayTable(taggedTemplateData)

return tests.forEach(row =>
cb(
row.title,
applyArguments(supportsDone, row.arguments, test),
timeout
)
needsEachError
? cb(
row.title,
applyArguments(supportsDone, row.arguments, test),
timeout,
error
)
: cb(
row.title,
applyArguments(supportsDone, row.arguments, test),
timeout
)
);
} catch (e) {
const error = new (_jestUtil().ErrorWithStack)(e.message, eachBind);
const err = new Error(e.message);
err.stack = error.stack?.replace(/^Error: /s, `Error: ${e.message}`);
return cb(title, () => {
throw error;
throw err;
});
}
};
};
return bindWrap;
}
const isArrayTable = data => data.length === 0;
const buildArrayTests = (title, table) => {

@@ -69,3 +70,2 @@ (0, _validation.validateArrayTable)(table);

};
const buildTemplateTests = (title, table, taggedTemplateData) => {

@@ -76,3 +76,2 @@ const headings = getHeadingKeys(table[0]);

};
const getHeadingKeys = headings =>

@@ -82,3 +81,2 @@ (0, _validation.extractValidTemplateHeadings)(headings)

.split('|');
const applyArguments = (supportsDone, params, test) =>

@@ -85,0 +83,0 @@ supportsDone && params.length < test.length

@@ -12,10 +12,4 @@ /**

supportsDone?: boolean,
): (
table: Global.EachTable,
...taggedTemplateData: Global.TemplateData
) => (
title: Global.BlockNameLike,
test: Global.EachTestFn<EachCallback>,
timeout?: number,
) => void;
needsEachError?: boolean,
): Global.EachTestFn<any>;

@@ -35,24 +29,8 @@ declare const each: {

timeout?: number,
): void;
skip: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
only: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
): any;
skip: any;
only: any;
};
fdescribe: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
fit: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
fdescribe: any;
fit: any;
it: {

@@ -63,13 +41,5 @@ (

timeout?: number,
): void;
skip: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
only: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
): any;
skip: any;
only: any;
concurrent: {

@@ -80,13 +50,5 @@ (

timeout?: number,
): void;
only: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
skip: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
): any;
only: any;
skip: any;
};

@@ -99,13 +61,5 @@ };

timeout?: number,
): void;
skip: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
only: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
): any;
skip: any;
only: any;
concurrent: {

@@ -116,30 +70,10 @@ (

timeout?: number,
): void;
only: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
skip: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
): any;
only: any;
skip: any;
};
};
xdescribe: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
xit: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
xtest: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
xdescribe: any;
xit: any;
xtest: any;
};

@@ -153,2 +87,3 @@ };

timeout?: number,
eachError?: Error,
) => void;

@@ -166,24 +101,8 @@

timeout?: number,
): void;
skip: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
only: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
): any;
skip: any;
only: any;
};
fdescribe: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
fit: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
fdescribe: any;
fit: any;
it: {

@@ -194,13 +113,5 @@ (

timeout?: number,
): void;
skip: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
only: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
): any;
skip: any;
only: any;
concurrent: {

@@ -211,13 +122,5 @@ (

timeout?: number,
): void;
only: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
skip: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
): any;
only: any;
skip: any;
};

@@ -230,13 +133,5 @@ };

timeout?: number,
): void;
skip: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
only: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
): any;
skip: any;
only: any;
concurrent: {

@@ -247,32 +142,12 @@ (

timeout?: number,
): void;
only: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
skip: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
): any;
only: any;
skip: any;
};
};
xdescribe: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
xit: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
xtest: (
title: Global.BlockNameLike,
test: Global.EachTestFn<Global.TestCallback>,
timeout?: number | undefined,
) => void;
xdescribe: any;
xit: any;
xtest: any;
};
export {};

@@ -13,9 +13,6 @@ 'use strict';

exports.default = void 0;
var _bind = _interopRequireDefault(require('./bind'));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
/**

@@ -28,6 +25,6 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

*/
const install = (g, table, ...data) => {
const bindingWithArray = data.length === 0;
const bindingWithTemplate = Array.isArray(table) && !!table.raw;
if (!bindingWithArray && !bindingWithTemplate) {

@@ -38,12 +35,8 @@ throw new Error(

}
const test = (title, test, timeout) =>
(0, _bind.default)(g.test)(table, ...data)(title, test, timeout);
test.skip = (0, _bind.default)(g.test.skip)(table, ...data);
test.only = (0, _bind.default)(g.test.only)(table, ...data);
const testConcurrent = (title, test, timeout) =>
(0, _bind.default)(g.test.concurrent)(table, ...data)(title, test, timeout);
test.concurrent = testConcurrent;

@@ -58,6 +51,4 @@ testConcurrent.only = (0, _bind.default)(g.test.concurrent.only)(

);
const it = (title, test, timeout) =>
(0, _bind.default)(g.it)(table, ...data)(title, test, timeout);
it.skip = (0, _bind.default)(g.it.skip)(table, ...data);

@@ -69,3 +60,2 @@ it.only = (0, _bind.default)(g.it.only)(table, ...data);

const xtest = (0, _bind.default)(g.xtest)(table, ...data);
const describe = (title, suite, timeout) =>

@@ -77,3 +67,2 @@ (0, _bind.default)(g.describe, false)(table, ...data)(

);
describe.skip = (0, _bind.default)(g.describe.skip, false)(table, ...data);

@@ -94,5 +83,3 @@ describe.only = (0, _bind.default)(g.describe.only, false)(table, ...data);

};
const each = (table, ...data) => install(globalThis, table, ...data);
each.withGlobal =

@@ -102,4 +89,3 @@ g =>

install(g, table, ...data);
var _default = each;
exports.default = _default;

@@ -7,25 +7,17 @@ 'use strict';

exports.default = array;
function util() {
const data = _interopRequireWildcard(require('util'));
util = function () {
return data;
};
return data;
}
function _prettyFormat() {
const data = require('pretty-format');
_prettyFormat = function () {
return data;
};
return data;
}
var _interpolation = require('./interpolation');
function _getRequireWildcardCache(nodeInterop) {

@@ -39,3 +31,2 @@ if (typeof WeakMap !== 'function') return null;

}
function _interopRequireWildcard(obj, nodeInterop) {

@@ -73,3 +64,2 @@ if (!nodeInterop && obj && obj.__esModule) {

}
/**

@@ -82,2 +72,3 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

*/
const SUPPORTED_PLACEHOLDERS = /%[sdifjoOp#]/g;

@@ -89,3 +80,2 @@ const PRETTY_PLACEHOLDER = '%p';

const JEST_EACH_PLACEHOLDER_ESCAPE = '@@__JEST_EACH_PLACEHOLDER_ESCAPE__@@';
function array(title, arrayTable) {

@@ -102,3 +92,2 @@ if (isTemplates(title, arrayTable)) {

}
return normaliseTable(arrayTable).map((row, index) => ({

@@ -109,3 +98,2 @@ arguments: row,

}
const isTemplates = (title, arrayTable) =>

@@ -115,9 +103,5 @@ !SUPPORTED_PLACEHOLDERS.test(interpolateEscapedPlaceholders(title)) &&

arrayTable.every(col => col != null && typeof col === 'object');
const normaliseTable = table => (isTable(table) ? table : table.map(colToRow));
const isTable = table => table.every(Array.isArray);
const colToRow = col => [col];
const formatTitle = (title, row, rowIndex) =>

@@ -134,3 +118,2 @@ row

.replace(new RegExp(JEST_EACH_PLACEHOLDER_ESCAPE, 'g'), PLACEHOLDER_PREFIX);
const normalisePlaceholderValue = value =>

@@ -143,12 +126,8 @@ typeof value === 'string'

: value;
const getMatchingPlaceholders = title =>
title.match(SUPPORTED_PLACEHOLDERS) || [];
const interpolateEscapedPlaceholders = title =>
title.replace(ESCAPED_PLACEHOLDER_PREFIX, JEST_EACH_PLACEHOLDER_ESCAPE);
const interpolateTitleIndex = (title, index) =>
title.replace(INDEX_PLACEHOLDER, index.toString());
const interpolatePrettyPlaceholder = (title, value) =>

@@ -155,0 +134,0 @@ title.replace(

@@ -8,23 +8,16 @@ 'use strict';

exports.interpolateVariables = void 0;
function _jestGetType() {
const data = require('jest-get-type');
_jestGetType = function () {
return data;
};
return data;
}
function _prettyFormat() {
const data = require('pretty-format');
_prettyFormat = function () {
return data;
};
return data;
}
/**

@@ -37,2 +30,3 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

*/
const interpolateVariables = (title, template, index) =>

@@ -43,16 +37,11 @@ Object.keys(template)

.replace('$#', `${index}`);
exports.interpolateVariables = interpolateVariables;
const getMatchingKeyPaths = title => (matches, key) =>
matches.concat(title.match(new RegExp(`\\$${key}[\\.\\w]*`, 'g')) || []);
const replaceKeyPathWithValue = template => (title, match) => {
const keyPath = match.replace('$', '').split('.');
const value = getPath(template, keyPath);
if ((0, _jestGetType().isPrimitive)(value)) {
return title.replace(match, String(value));
}
return title.replace(

@@ -66,2 +55,3 @@ match,

};
/* eslint import/export: 0*/

@@ -68,0 +58,0 @@

@@ -7,5 +7,3 @@ 'use strict';

exports.default = template;
var _interpolation = require('./interpolation');
/**

@@ -18,2 +16,3 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

*/
function template(title, headings, row) {

@@ -27,3 +26,2 @@ const table = convertRowToTable(row, headings);

}
const convertRowToTable = (row, headings) =>

@@ -38,3 +36,2 @@ Array.from({

);
const convertTableToTemplates = (table, headings) =>

@@ -41,0 +38,0 @@ table.map(row =>

@@ -10,27 +10,19 @@ 'use strict';

void 0;
function _chalk() {
const data = _interopRequireDefault(require('chalk'));
_chalk = function () {
return data;
};
return data;
}
function _prettyFormat() {
const data = require('pretty-format');
_prettyFormat = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {default: obj};
}
/**

@@ -43,6 +35,5 @@ * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

*/
const EXPECTED_COLOR = _chalk().default.green;
const RECEIVED_COLOR = _chalk().default.red;
const validateArrayTable = table => {

@@ -58,3 +49,2 @@ if (!Array.isArray(table)) {

}
if (isTaggedTemplateLiteral(table)) {

@@ -66,3 +56,2 @@ if (isEmptyString(table[0])) {

}
throw new Error(

@@ -72,3 +61,2 @@ 'Error: `.each` called with a Tagged Template Literal with no data, remember to interpolate with ${expression} syntax.\n'

}
if (isEmptyTable(table)) {

@@ -80,15 +68,9 @@ throw new Error(

};
exports.validateArrayTable = validateArrayTable;
const isTaggedTemplateLiteral = array => array.raw !== undefined;
const isEmptyTable = table => table.length === 0;
const isEmptyString = str => typeof str === 'string' && str.trim() === '';
const validateTemplateTableArguments = (headings, data) => {
const incompleteData = data.length % headings.length;
const missingData = headings.length - incompleteData;
if (incompleteData > 0) {

@@ -107,7 +89,4 @@ throw new Error(

};
exports.validateTemplateTableArguments = validateTemplateTableArguments;
const pluralize = (word, count) => word + (count === 1 ? '' : 's');
const START_OF_LINE = '^';

@@ -122,6 +101,4 @@ const NEWLINE = '\\n';

);
const extractValidTemplateHeadings = headings => {
const matches = headings.match(HEADINGS_FORMAT);
if (matches === null) {

@@ -136,6 +113,4 @@ throw new Error(

}
return matches[0];
};
exports.extractValidTemplateHeadings = extractValidTemplateHeadings;
{
"name": "jest-each",
"version": "29.1.2",
"version": "29.2.0",
"description": "Parameterised tests for Jest",

@@ -28,7 +28,7 @@ "main": "./build/index.js",

"dependencies": {
"@jest/types": "^29.1.2",
"@jest/types": "^29.2.0",
"chalk": "^4.0.0",
"jest-get-type": "^29.0.0",
"jest-util": "^29.1.2",
"pretty-format": "^29.1.2"
"jest-get-type": "^29.2.0",
"jest-util": "^29.2.0",
"pretty-format": "^29.2.0"
},

@@ -41,3 +41,3 @@ "engines": {

},
"gitHead": "3c31dd619e8c022cde53f40fa12ea2a67f4752ce"
"gitHead": "ee5b37a4f4433afcfffb0356cea47739d8092287"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc