How to use the concordance.compare function in concordance

To help you get started, we’ve selected a few concordance examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hildjj / node-cbor / test / implementation_matrix.js View on Github external
function deepEqual(actual, expected) {
  const ret = concordance.compare(actual, expected)
  if (!ret.pass) {
    const a = ret.actual || concordance.describe(actual)
    const e = ret.expected || concordance.describe(expected)
    return false
  }
  return true
}
github avajs / ava / lib / assert.js View on Github external
this.is = withSkip((actual, expected, message) => {
			if (!checkMessage('is', message)) {
				return;
			}

			if (Object.is(actual, expected)) {
				pass();
			} else {
				const result = concordance.compare(actual, expected, concordanceOptions);
				const actualDescriptor = result.actual || concordance.describe(actual, concordanceOptions);
				const expectedDescriptor = result.expected || concordance.describe(expected, concordanceOptions);

				if (result.pass) {
					fail(new AssertionError({
						assertion: 'is',
						message,
						raw: {actual, expected},
						values: [formatDescriptorWithLabel('Values are deeply equal to each other, but they are not the same:', actualDescriptor)]
					}));
				} else {
					fail(new AssertionError({
						assertion: 'is',
						message,
						raw: {actual, expected},
						values: [formatDescriptorDiff(actualDescriptor, expectedDescriptor)]
github MGMonge / petrol / core / TestCase.js View on Github external
assertEquals(expected, actual, message = '') {
        if (!concordance.compare(expected, actual).pass) {
            throw new AssertionError({message : `${message}\n${concordance.diff(expected, actual)}`});
        }
    }
github MGMonge / petrol / core / TestCase.js View on Github external
assertNotEquals(expected, actual, message = '') {
        if (concordance.compare(expected, actual).pass) {
            let defaultMessage = `Expected value is equal to actual value`;

            throw new AssertionError({message: message || defaultMessage});
        }
    }
github otissv / remodule / node_modules / ava / lib / assert.js View on Github external
deepEqual(actual, expected, message) {
			const result = concordance.compare(actual, expected, concordanceOptions);
			if (result.pass) {
				pass(this);
			} else {
				const actualDescriptor = result.actual || concordance.describe(actual, concordanceOptions);
				const expectedDescriptor = result.expected || concordance.describe(expected, concordanceOptions);
				fail(this, new AssertionError({
					assertion: 'deepEqual',
					message,
					raw: {actual, expected},
					values: [formatDescriptorDiff(actualDescriptor, expectedDescriptor)]
				}));
			}
		},
github otissv / remodule / node_modules / ava / lib / assert.js View on Github external
notDeepEqual(actual, expected, message) {
			const result = concordance.compare(actual, expected, concordanceOptions);
			if (result.pass) {
				const actualDescriptor = result.actual || concordance.describe(actual, concordanceOptions);
				fail(this, new AssertionError({
					assertion: 'notDeepEqual',
					message,
					raw: {actual, expected},
					values: [formatDescriptorWithLabel('Value is deeply equal:', actualDescriptor)]
				}));
			} else {
				pass(this);
			}
		},
github serverless / components / registry / github-webhook / src / diff.js View on Github external
module.exports = function diffValues(actual, expected) {
  const result = concordance.compare(actual, expected, concordanceOptions)
  if (result.pass) {
    return null
  }
  const actualDescriptor = result.actual || concordance.describe(actual, concordanceOptions)
  const expectedDescriptor = result.expected || concordance.describe(expected, concordanceOptions)

  return formatDescriptorDiff(actualDescriptor, expectedDescriptor)
}

concordance

Compare, format, diff and serialize any JavaScript value

ISC
Latest version published 4 years ago

Package Health Score

65 / 100
Full package analysis