Fix dependabot issues

This commit is contained in:
Andrew Eisenberg 2021-10-21 15:24:20 -07:00
parent c89d9bd8b0
commit 531c6ba7c8
705 changed files with 53406 additions and 20466 deletions

108
node_modules/ava/lib/assert.js generated vendored
View file

@ -3,11 +3,11 @@ const concordance = require('concordance');
const isError = require('is-error');
const isPromise = require('is-promise');
const concordanceOptions = require('./concordance-options').default;
const concordanceDiffOptions = require('./concordance-options').diff;
const {CIRCULAR_SELECTOR, isLikeSelector, selectComparable} = require('./like-selector');
const snapshotManager = require('./snapshot-manager');
function formatDescriptorDiff(actualDescriptor, expectedDescriptor, options) {
options = {...options, ...concordanceDiffOptions};
options = {...options, ...concordanceOptions};
return {
label: 'Difference:',
formatted: concordance.diffDescriptors(actualDescriptor, expectedDescriptor, options)
@ -64,6 +64,21 @@ class AssertionError extends Error {
}
exports.AssertionError = AssertionError;
function checkAssertionMessage(assertion, message) {
if (typeof message === 'undefined' || typeof message === 'string') {
return true;
}
return new AssertionError({
assertion,
improperUsage: true,
message: 'The assertion message must be a string',
values: [formatWithLabel('Called with:', message)]
});
}
exports.checkAssertionMessage = checkAssertionMessage;
function getErrorWithLongStackTrace() {
const limitBefore = Error.stackTraceLimit;
Error.stackTraceLimit = Infinity;
@ -72,8 +87,16 @@ function getErrorWithLongStackTrace() {
return err;
}
function validateExpectations(assertion, expectations, numberArgs) { // eslint-disable-line complexity
function validateExpectations(assertion, expectations, numberArgs, experiments) { // eslint-disable-line complexity
if (numberArgs === 1 || expectations === null || expectations === undefined) {
if (experiments.disableNullExpectations && expectations === null) {
throw new AssertionError({
assertion,
message: `The second argument to \`t.${assertion}()\` must be an expectation object or \`undefined\``,
values: [formatWithLabel('Called with:', expectations)]
});
}
expectations = {};
} else if (
typeof expectations === 'function' ||
@ -242,7 +265,9 @@ class Assertions {
fail = notImplemented,
skip = notImplemented,
compareWithSnapshot = notImplemented,
powerAssert
powerAssert,
experiments = {},
disableSnapshots = false
} = {}) {
const withSkip = assertionFn => {
assertionFn.skip = skip;
@ -267,22 +292,16 @@ class Assertions {
});
const checkMessage = (assertion, message, powerAssert = false) => {
if (typeof message === 'undefined' || typeof message === 'string') {
return true;
const result = checkAssertionMessage(assertion, message);
if (result === true) {
return this.true;
}
const error = new AssertionError({
assertion,
improperUsage: true,
message: 'The assertion message must be a string',
values: [formatWithLabel('Called with:', message)]
});
if (powerAssert) {
throw error;
throw result;
}
fail(error);
fail(result);
return false;
};
@ -387,6 +406,52 @@ class Assertions {
}
});
this.like = withSkip((actual, selector, message) => {
if (!checkMessage('like', message)) {
return;
}
if (!isLikeSelector(selector)) {
fail(new AssertionError({
assertion: 'like',
improperUsage: true,
message: '`t.like()` selector must be a non-empty object',
values: [formatWithLabel('Called with:', selector)]
}));
return;
}
let comparable;
try {
comparable = selectComparable(actual, selector);
} catch (error) {
if (error === CIRCULAR_SELECTOR) {
fail(new AssertionError({
assertion: 'like',
improperUsage: true,
message: '`t.like()` selector must not contain circular references',
values: [formatWithLabel('Called with:', selector)]
}));
return;
}
throw error;
}
const result = concordance.compare(comparable, selector, concordanceOptions);
if (result.pass) {
pass();
} else {
const actualDescriptor = result.actual || concordance.describe(comparable, concordanceOptions);
const expectedDescriptor = result.expected || concordance.describe(selector, concordanceOptions);
fail(new AssertionError({
assertion: 'like',
message,
values: [formatDescriptorDiff(actualDescriptor, expectedDescriptor)]
}));
}
});
this.throws = withSkip((...args) => {
// Since arrow functions do not support 'arguments', we are using rest
// operator, so we can determine the total number of arguments passed
@ -408,7 +473,7 @@ class Assertions {
}
try {
expectations = validateExpectations('throws', expectations, args.length);
expectations = validateExpectations('throws', expectations, args.length, experiments);
} catch (error) {
fail(error);
return;
@ -474,7 +539,7 @@ class Assertions {
}
try {
expectations = validateExpectations('throwsAsync', expectations, args.length);
expectations = validateExpectations('throwsAsync', expectations, args.length, experiments);
} catch (error) {
fail(error);
return Promise.resolve();
@ -634,6 +699,15 @@ class Assertions {
});
this.snapshot = withSkip((expected, ...rest) => {
if (disableSnapshots && experiments.disableSnapshotsInHooks) {
fail(new AssertionError({
assertion: 'snapshot',
message: '`t.snapshot()` can only be used in tests',
improperUsage: true
}));
return;
}
let message;
let snapshotOptions;
if (rest.length > 1) {