jest-matcher-utils
Advanced tools
Comparing version 14.3.0-alpha.d13c163e to 14.3.1-alpha.410cb91a
@@ -27,2 +27,5 @@ /** | ||
const EXPECTED_COLOR = chalk.green; | ||
const RECEIVED_COLOR = chalk.red; | ||
// get the type of a value with handling the edge cases like `typeof []` | ||
@@ -94,4 +97,4 @@ // and `typeof null` | ||
const highlight = object => chalk.red(stringify(object)); | ||
const printExpected = value => chalk.green(stringify(value)); | ||
const printReceived = object => RECEIVED_COLOR(stringify(object)); | ||
const printExpected = value => EXPECTED_COLOR(stringify(value)); | ||
@@ -130,3 +133,18 @@ const ensureNoExpected = (expected, matcherName) => { | ||
const pluralize = | ||
(word, count) => `${ count } ${ word }${ count === 1 ? '' : 's' }`; | ||
const matcherHint = function ( | ||
matcherName) | ||
{let received = arguments.length <= 1 || arguments[1] === undefined ? 'received' : arguments[1];let expected = arguments.length <= 2 || arguments[2] === undefined ? 'expected' : arguments[2]; | ||
return chalk.dim('expect(') + RECEIVED_COLOR(received) + | ||
chalk.dim(')' + matcherName + '(') + | ||
EXPECTED_COLOR(expected) + chalk.dim(')'); | ||
}; | ||
module.exports = { | ||
EXPECTED_COLOR, | ||
RECEIVED_COLOR, | ||
ensureActualIsNumber, | ||
@@ -137,4 +155,6 @@ ensureExpectedIsNumber, | ||
getType, | ||
highlight, | ||
matcherHint, | ||
pluralize, | ||
printExpected, | ||
printReceived, | ||
stringify }; |
{ | ||
"name": "jest-matcher-utils", | ||
"description": "A set of utility functions for jest-matchers and related packages", | ||
"version": "14.3.0-alpha.d13c163e", | ||
"version": "14.3.1-alpha.410cb91a", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
4534
125