How to use the jest-matcher-utils.pluralize function in jest-matcher-utils

To help you get started, we’ve selected a few jest-matcher-utils 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 DefinitelyTyped / DefinitelyTyped / types / jest-matcher-utils / jest-matcher-utils-tests.ts View on Github external
utils.ensureActualIsNumber(66); // $ExpectType void
utils.ensureActualIsNumber(66, 'highwayRouteMatcher');
utils.ensureActualIsNumber('66', 'highwayRouteMatcher');

utils.ensureExpectedIsNumber(66); // $ExpectType void
utils.ensureExpectedIsNumber(66, 'highwayRouteMatcher');
utils.ensureExpectedIsNumber('66', 'highwayRouteMatcher');

utils.ensureNumbers(66, 66); // $ExpectType void
utils.ensureNumbers(66, 66, 'highwayRouteMatcher');
utils.ensureNumbers('66', 'highwayRouteMatcher');
utils.ensureNumbers(66); // $ExpectError

utils.pluralize('fox', 1); // $ExpectType string
utils.pluralize('fox', 9);
utils.pluralize('fox', 'a yuge number'); // $ExpectError
utils.pluralize(1, 2); // $ExpectError

utils.matcherHint('[.not]primeNumberMatcher'); // $ExpectType string
utils.matcherHint('[.not]primeNumberMatcher', '12');
utils.matcherHint('[.not]primeNumberMatcher', '12', '13');
utils.matcherHint('[.not]primeNumberMatcher', '12', '13', {});
utils.matcherHint('[.not]primeNumberMatcher', '12', '13', {
    secondArgument: ''
});
utils.matcherHint('[.not]primeNumberMatcher', '12', '13', {
    secondArgument: '',
    isDirectExpectCall: true
});
utils.matcherHint('[.not]primeNumberMatcher', '12', '13', {
    secondArgument: '',
    isDirectExpectCall: true,
github DefinitelyTyped / DefinitelyTyped / types / jest-matcher-utils / jest-matcher-utils-tests.ts View on Github external
utils.ensureActualIsNumber(66); // $ExpectType void
utils.ensureActualIsNumber(66, 'highwayRouteMatcher');
utils.ensureActualIsNumber('66', 'highwayRouteMatcher');

utils.ensureExpectedIsNumber(66); // $ExpectType void
utils.ensureExpectedIsNumber(66, 'highwayRouteMatcher');
utils.ensureExpectedIsNumber('66', 'highwayRouteMatcher');

utils.ensureNumbers(66, 66); // $ExpectType void
utils.ensureNumbers(66, 66, 'highwayRouteMatcher');
utils.ensureNumbers('66', 'highwayRouteMatcher');
utils.ensureNumbers(66); // $ExpectError

utils.pluralize('fox', 1); // $ExpectType string
utils.pluralize('fox', 9);
utils.pluralize('fox', 'a yuge number'); // $ExpectError
utils.pluralize(1, 2); // $ExpectError

utils.matcherHint('[.not]primeNumberMatcher'); // $ExpectType string
utils.matcherHint('[.not]primeNumberMatcher', '12');
utils.matcherHint('[.not]primeNumberMatcher', '12', '13');
utils.matcherHint('[.not]primeNumberMatcher', '12', '13', {});
utils.matcherHint('[.not]primeNumberMatcher', '12', '13', {
    secondArgument: ''
});
utils.matcherHint('[.not]primeNumberMatcher', '12', '13', {
    secondArgument: '',
    isDirectExpectCall: true
});
utils.matcherHint('[.not]primeNumberMatcher', '12', '13', {
    secondArgument: '',
github DefinitelyTyped / DefinitelyTyped / types / jest-matcher-utils / jest-matcher-utils-tests.ts View on Github external
utils.ensureNoExpected('', '');

utils.ensureActualIsNumber(66); // $ExpectType void
utils.ensureActualIsNumber(66, 'highwayRouteMatcher');
utils.ensureActualIsNumber('66', 'highwayRouteMatcher');

utils.ensureExpectedIsNumber(66); // $ExpectType void
utils.ensureExpectedIsNumber(66, 'highwayRouteMatcher');
utils.ensureExpectedIsNumber('66', 'highwayRouteMatcher');

utils.ensureNumbers(66, 66); // $ExpectType void
utils.ensureNumbers(66, 66, 'highwayRouteMatcher');
utils.ensureNumbers('66', 'highwayRouteMatcher');
utils.ensureNumbers(66); // $ExpectError

utils.pluralize('fox', 1); // $ExpectType string
utils.pluralize('fox', 9);
utils.pluralize('fox', 'a yuge number'); // $ExpectError
utils.pluralize(1, 2); // $ExpectError

utils.matcherHint('[.not]primeNumberMatcher'); // $ExpectType string
utils.matcherHint('[.not]primeNumberMatcher', '12');
utils.matcherHint('[.not]primeNumberMatcher', '12', '13');
utils.matcherHint('[.not]primeNumberMatcher', '12', '13', {});
utils.matcherHint('[.not]primeNumberMatcher', '12', '13', {
    secondArgument: ''
});
utils.matcherHint('[.not]primeNumberMatcher', '12', '13', {
    secondArgument: '',
    isDirectExpectCall: true
});
utils.matcherHint('[.not]primeNumberMatcher', '12', '13', {
github DefinitelyTyped / DefinitelyTyped / types / jest-matcher-utils / jest-matcher-utils-tests.ts View on Github external
utils.ensureActualIsNumber(66, 'highwayRouteMatcher');
utils.ensureActualIsNumber('66', 'highwayRouteMatcher');

utils.ensureExpectedIsNumber(66); // $ExpectType void
utils.ensureExpectedIsNumber(66, 'highwayRouteMatcher');
utils.ensureExpectedIsNumber('66', 'highwayRouteMatcher');

utils.ensureNumbers(66, 66); // $ExpectType void
utils.ensureNumbers(66, 66, 'highwayRouteMatcher');
utils.ensureNumbers('66', 'highwayRouteMatcher');
utils.ensureNumbers(66); // $ExpectError

utils.pluralize('fox', 1); // $ExpectType string
utils.pluralize('fox', 9);
utils.pluralize('fox', 'a yuge number'); // $ExpectError
utils.pluralize(1, 2); // $ExpectError

utils.matcherHint('[.not]primeNumberMatcher'); // $ExpectType string
utils.matcherHint('[.not]primeNumberMatcher', '12');
utils.matcherHint('[.not]primeNumberMatcher', '12', '13');
utils.matcherHint('[.not]primeNumberMatcher', '12', '13', {});
utils.matcherHint('[.not]primeNumberMatcher', '12', '13', {
    secondArgument: ''
});
utils.matcherHint('[.not]primeNumberMatcher', '12', '13', {
    secondArgument: '',
    isDirectExpectCall: true
});
utils.matcherHint('[.not]primeNumberMatcher', '12', '13', {
    secondArgument: '',
    isDirectExpectCall: true,
    notAnOption: 'notAnOptionValue' // $ExpectError
github facebook / jest / packages / jest-matchers / src / extractExpectedAssertionsErrors.js View on Github external
const extractExpectedAssertionsErrors = () => {
  const result = [];
  const {
    assertionCalls,
    expectedAssertionsNumber,
    isExpectingAssertions,
  } = getState();
  setState({assertionCalls: 0, expectedAssertionsNumber: null});
  if (
    typeof expectedAssertionsNumber === 'number' &&
    assertionCalls !== expectedAssertionsNumber
  ) {
    const numOfAssertionsExpected = EXPECTED_COLOR(
      pluralize('assertion', expectedAssertionsNumber),
    );
    const error = new Error(
      matcherHint('.assertions', '', String(expectedAssertionsNumber), {
        isDirectExpectCall: true,
      }) +
        '\n\n' +
        `Expected ${numOfAssertionsExpected} to be called but only received ` +
        RECEIVED_COLOR(pluralize('assertion call', assertionCalls || 0)) +
        '.',
    );
    result.push({
      actual: assertionCalls,
      error,
      expected: expectedAssertionsNumber,
    });
  }
github facebook / jest / packages / jest-matchers / src / extractExpectedAssertionsErrors.js View on Github external
} = getState();
  setState({assertionCalls: 0, expectedAssertionsNumber: null});
  if (
    typeof expectedAssertionsNumber === 'number' &&
    assertionCalls !== expectedAssertionsNumber
  ) {
    const numOfAssertionsExpected = EXPECTED_COLOR(
      pluralize('assertion', expectedAssertionsNumber),
    );
    const error = new Error(
      matcherHint('.assertions', '', String(expectedAssertionsNumber), {
        isDirectExpectCall: true,
      }) +
        '\n\n' +
        `Expected ${numOfAssertionsExpected} to be called but only received ` +
        RECEIVED_COLOR(pluralize('assertion call', assertionCalls || 0)) +
        '.',
    );
    result.push({
      actual: assertionCalls,
      error,
      expected: expectedAssertionsNumber,
    });
  }
  if (isExpectingAssertions && assertionCalls === 0) {
    const expected = EXPECTED_COLOR('at least one assertion');
    const received = RECEIVED_COLOR('received none');
    const error = new Error(
      matcherHint('.hasAssertions', '', '', {
        isDirectExpectCall: true,
      }) +
        '\n\n' +