jest-each
Advanced tools
Comparing version 30.0.0-alpha.2 to 30.0.0-alpha.3
@@ -45,3 +45,3 @@ /*! | ||
const bindWrap = (table, ...taggedTemplateData) => { | ||
const error = new (_jestUtil().ErrorWithStack)(undefined, bindWrap); | ||
const errorWithStack = new (_jestUtil().ErrorWithStack)(undefined, bindWrap); | ||
return function eachBind(title, test, timeout) { | ||
@@ -52,8 +52,8 @@ title = (0, _jestUtil().convertDescriptorToString)(title); | ||
for (const row of tests) { | ||
needsEachError ? cb(row.title, applyArguments(supportsDone, row.arguments, test), timeout, error) : cb(row.title, applyArguments(supportsDone, row.arguments, test), timeout); | ||
needsEachError ? cb(row.title, applyArguments(supportsDone, row.arguments, test), timeout, errorWithStack) : cb(row.title, applyArguments(supportsDone, row.arguments, test), timeout); | ||
} | ||
return; | ||
} catch (e) { | ||
const err = new Error(e.message); | ||
err.stack = error.stack?.replace(/^Error: /s, `Error: ${e.message}`); | ||
} catch (error) { | ||
const err = new Error(error.message); | ||
err.stack = errorWithStack.stack?.replace(/^Error: /s, `Error: ${error.message}`); | ||
return cb(title, () => { | ||
@@ -77,3 +77,3 @@ throw err; | ||
}; | ||
const getHeadingKeys = headings => (0, _validation.extractValidTemplateHeadings)(headings).replace(/\s/g, '').split('|'); | ||
const getHeadingKeys = headings => (0, _validation.extractValidTemplateHeadings)(headings).replaceAll(/\s/g, '').split('|'); | ||
const applyArguments = (supportsDone, params, test) => supportsDone && params.length < test.length ? done => test(...params, done) : () => test(...params); | ||
@@ -117,3 +117,3 @@ | ||
const SUPPORTED_PLACEHOLDERS = /%[sdifjoOp#]/g; | ||
const SUPPORTED_PLACEHOLDERS = /%[#Odfijops]/g; | ||
const PRETTY_PLACEHOLDER = '%p'; | ||
@@ -128,3 +128,3 @@ const INDEX_PLACEHOLDER = '%#'; | ||
arguments: [template], | ||
title: (0, _interpolation.interpolateVariables)(title, template, index).replace(ESCAPED_PLACEHOLDER_PREFIX, PLACEHOLDER_PREFIX) | ||
title: (0, _interpolation.interpolateVariables)(title, template, index).replaceAll(ESCAPED_PLACEHOLDER_PREFIX, PLACEHOLDER_PREFIX) | ||
})); | ||
@@ -147,6 +147,6 @@ } | ||
return util().format(formattedTitle, normalisedValue); | ||
}, interpolateTitleIndex(interpolateEscapedPlaceholders(title), rowIndex)).replace(new RegExp(JEST_EACH_PLACEHOLDER_ESCAPE, 'g'), PLACEHOLDER_PREFIX); | ||
const normalisePlaceholderValue = value => typeof value === 'string' ? value.replace(new RegExp(PLACEHOLDER_PREFIX, 'g'), JEST_EACH_PLACEHOLDER_ESCAPE) : value; | ||
}, interpolateTitleIndex(interpolateEscapedPlaceholders(title), rowIndex)).replaceAll(new RegExp(JEST_EACH_PLACEHOLDER_ESCAPE, 'g'), PLACEHOLDER_PREFIX); | ||
const normalisePlaceholderValue = value => typeof value === 'string' ? value.replaceAll(new RegExp(PLACEHOLDER_PREFIX, 'g'), JEST_EACH_PLACEHOLDER_ESCAPE) : value; | ||
const getMatchingPlaceholders = title => title.match(SUPPORTED_PLACEHOLDERS) || []; | ||
const interpolateEscapedPlaceholders = title => title.replace(ESCAPED_PLACEHOLDER_PREFIX, JEST_EACH_PLACEHOLDER_ESCAPE); | ||
const interpolateEscapedPlaceholders = title => title.replaceAll(ESCAPED_PLACEHOLDER_PREFIX, JEST_EACH_PLACEHOLDER_ESCAPE); | ||
const interpolateTitleIndex = (title, index) => title.replace(INDEX_PLACEHOLDER, index.toString()); | ||
@@ -192,3 +192,3 @@ const interpolatePrettyPlaceholder = (title, value) => title.replace(PRETTY_PLACEHOLDER, (0, _prettyFormat().format)(value, { | ||
const interpolateVariables = (title, template, index) => title.replace(new RegExp(`\\$(${Object.keys(template).join('|')})[.\\w]*`, 'g'), match => { | ||
const interpolateVariables = (title, template, index) => title.replaceAll(new RegExp(`\\$(${Object.keys(template).join('|')})[.\\w]*`, 'g'), match => { | ||
const keyPath = match.slice(1).split('.'); | ||
@@ -240,5 +240,3 @@ const value = getPath(template, keyPath); | ||
}, (_, index) => row.slice(index * headings.length, index * headings.length + headings.length)); | ||
const convertTableToTemplates = (table, headings) => table.map(row => row.reduce((acc, value, index) => Object.assign(acc, { | ||
[headings[index]]: value | ||
}), {})); | ||
const convertTableToTemplates = (table, headings) => table.map(row => Object.fromEntries(row.map((value, index) => [headings[index], value]))); | ||
@@ -283,3 +281,3 @@ /***/ }), | ||
if (!Array.isArray(table)) { | ||
throw new Error('`.each` must be called with an Array or Tagged Template Literal.\n\n' + `Instead was called with: ${(0, _prettyFormat().format)(table, { | ||
throw new TypeError('`.each` must be called with an Array or Tagged Template Literal.\n\n' + `Instead was called with: ${(0, _prettyFormat().format)(table, { | ||
maxDepth: 1, | ||
@@ -286,0 +284,0 @@ min: true |
{ | ||
"name": "jest-each", | ||
"version": "30.0.0-alpha.2", | ||
"version": "30.0.0-alpha.3", | ||
"description": "Parameterised tests for Jest", | ||
@@ -30,7 +30,7 @@ "main": "./build/index.js", | ||
"dependencies": { | ||
"@jest/types": "30.0.0-alpha.2", | ||
"@jest/types": "30.0.0-alpha.3", | ||
"chalk": "^4.0.0", | ||
"jest-get-type": "30.0.0-alpha.2", | ||
"jest-util": "30.0.0-alpha.2", | ||
"pretty-format": "30.0.0-alpha.2" | ||
"jest-get-type": "30.0.0-alpha.3", | ||
"jest-util": "30.0.0-alpha.3", | ||
"pretty-format": "30.0.0-alpha.3" | ||
}, | ||
@@ -43,3 +43,3 @@ "engines": { | ||
}, | ||
"gitHead": "c04d13d7abd22e47b0997f6027886aed225c9ce4" | ||
"gitHead": "e267aff33d105399f2134bad7c8f82285104f3da" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34963
518
+ Added@jest/schemas@30.0.0-alpha.3(transitive)
+ Added@jest/types@30.0.0-alpha.3(transitive)
+ Added@sinclair/typebox@0.32.35(transitive)
+ Addedjest-get-type@30.0.0-alpha.3(transitive)
+ Addedjest-util@30.0.0-alpha.3(transitive)
+ Addedpretty-format@30.0.0-alpha.3(transitive)
- Removed@jest/schemas@30.0.0-alpha.2(transitive)
- Removed@jest/types@30.0.0-alpha.2(transitive)
- Removed@sinclair/typebox@0.31.28(transitive)
- Removedjest-get-type@30.0.0-alpha.2(transitive)
- Removedjest-util@30.0.0-alpha.2(transitive)
- Removedpretty-format@30.0.0-alpha.2(transitive)
Updated@jest/types@30.0.0-alpha.3
Updatedjest-get-type@30.0.0-alpha.3
Updatedjest-util@30.0.0-alpha.3
Updatedpretty-format@30.0.0-alpha.3