Comparing version 1.0.67 to 1.0.68
@@ -71,2 +71,15 @@ /** | ||
/** | ||
* Assert that a string is included in another, or object is included in an array. | ||
* | ||
* @example | ||
* ```javascript | ||
* assertIncludes('foobar', 'foo'); | ||
* assertIncludes([9, 5, 3], 5); | ||
* ``` | ||
* @param {string|array} haystack The thing to search in. | ||
* @param {string|array} needle The thing to search for. | ||
* @param {string?} message Optional error message if the assertion does not hold. | ||
*/ | ||
export function assertIncludes(haystack: string | any[], needle: string | any[], message?: string): void; | ||
/** | ||
* Assert `x < y`. | ||
@@ -73,0 +86,0 @@ * @param {number|BigInt} x The ostensibly smaller value. |
@@ -79,3 +79,27 @@ 'use strict'; | ||
/** | ||
* Assert that a string is included in another, or object is included in an array. | ||
* | ||
* @example | ||
* ```javascript | ||
* assertIncludes('foobar', 'foo'); | ||
* assertIncludes([9, 5, 3], 5); | ||
* ``` | ||
* @param {string|array} haystack The thing to search in. | ||
* @param {string|array} needle The thing to search for. | ||
* @param {string?} message Optional error message if the assertion does not hold. | ||
*/ | ||
function assertIncludes(haystack, needle, message = undefined) { | ||
lazyAssert( | ||
haystack.includes, () => `Haystack object ${haystack} does not have an includes method`); | ||
lazyAssert( | ||
haystack.includes(needle), | ||
() => ( | ||
`Expected ${JSON.stringify(haystack)} to include ${JSON.stringify(needle)}.` + | ||
(message ? ' ' + message : '') | ||
) | ||
); | ||
} | ||
/** | ||
@@ -196,2 +220,3 @@ * Assert that a condition is eventually true. | ||
assertGreaterEqual, | ||
assertIncludes, | ||
assertLess, | ||
@@ -198,0 +223,0 @@ assertLessEqual, |
@@ -65,3 +65,3 @@ const assert = require('assert').strict; | ||
if (! Object.keys(init.headers).find(h => h.toLowerCase() === 'user-agent')) { | ||
init.headers['User-Agent'] = 'pentf integration test (https://github.com/boxine/pentf)'; | ||
init.headers['User-Agent'] = 'pentf e2etest (https://github.com/boxine/pentf)'; | ||
} | ||
@@ -68,0 +68,0 @@ |
@@ -7,2 +7,3 @@ // Functions to output the current state. | ||
const kolorist = require('kolorist'); | ||
const errorstacks = require('errorstacks'); | ||
@@ -253,2 +254,17 @@ const utils = require('./utils'); | ||
/** | ||
* Mark a string as a link for terminals that support this (GNOME Terminal) | ||
* @param {*} config | ||
* @param {string} text | ||
* @param {string} target | ||
* @hidden | ||
*/ | ||
function link(config, text, target) { | ||
if (!config.colors) { | ||
return text; | ||
} | ||
return kolorist.link(text, target); | ||
} | ||
/** | ||
* Format the error | ||
@@ -265,4 +281,15 @@ * @param {*} config Penf config object | ||
return diff + err.stack | ||
.split('\n') | ||
const stack = errorstacks.parseStackTrace(err.stack) | ||
.map(frame => { | ||
if (frame.name) { | ||
const location = link(config, frame.fileName, `file://${frame.fileName}`); | ||
return color(config, 'dim', ` at ${frame.name} (`) + color(config, 'cyan', location) + color(config, 'dim', `:${frame.line}:${frame.column})`); | ||
} else { | ||
// Internal native code in node | ||
return color(config, 'dim', frame.raw); | ||
} | ||
}); | ||
const message = `${err.name}: ${err.message}`; | ||
return '\n' + diff + ([message, ...stack]) | ||
// Indent stack trace | ||
@@ -269,0 +296,0 @@ .map(line => ' ' + line) |
{ | ||
"name": "pentf", | ||
"version": "1.0.67", | ||
"version": "1.0.68", | ||
"description": "parallel end-to-end test framework", | ||
@@ -18,2 +18,3 @@ "main": "index.js", | ||
"emailjs-mime-parser": "^2.0.5", | ||
"errorstacks": "^1.1.5", | ||
"form-data": "^2.3.3", | ||
@@ -20,0 +21,0 @@ "glob": "^7.1.6", |
@@ -20,3 +20,8 @@ /* eslint no-console: 0 */ | ||
async function run_task(config, task) { | ||
const task_config = {...config, _browser_pages: []}; | ||
const task_config = { | ||
...config, | ||
_browser_pages: [], | ||
_testName: task.tc.name, | ||
_taskName: task.name, | ||
}; | ||
try { | ||
@@ -23,0 +28,0 @@ await task.tc.run(task_config); |
@@ -19,2 +19,3 @@ /** | ||
* @param {string?} prefix Text to put before the random characters. | ||
If no prefix is specified, the test name is used if available. | ||
* @returns {string} If `config.email` is `'foo@bar.com'`, something like `foo+prefix129ad12@bar.com` | ||
@@ -21,0 +22,0 @@ */ |
@@ -15,5 +15,9 @@ const assert = require('assert').strict; | ||
* @param {string?} prefix Text to put before the random characters. | ||
If no prefix is specified, the test name is used if available. | ||
* @returns {string} If `config.email` is `'foo@bar.com'`, something like `foo+prefix129ad12@bar.com` | ||
*/ | ||
function makeRandomEmail(config, prefix='') { | ||
function makeRandomEmail(config, prefix=undefined) { | ||
if (prefix === undefined) { | ||
prefix = config._testName || ''; | ||
} | ||
return makeEmailAddress(config, prefix + Math.random().toString(36).slice(2)); | ||
@@ -20,0 +24,0 @@ } |
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
271913
100
6120
19
+ Addederrorstacks@^1.1.5
+ Addederrorstacks@1.3.0(transitive)