jest-matcher-utils
Advanced tools
Comparing version 14.2.2-alpha.22bd3c33 to 14.3.0-alpha.d13c163e
@@ -13,4 +13,16 @@ /** | ||
const chalk = require('chalk'); | ||
// get the type of a value with handling the edge cases like `typeof []` | ||
@@ -34,2 +46,5 @@ // and `typeof null` | ||
} else if (typeof value === 'object') { | ||
if (value.constructor === RegExp) { | ||
return 'regexp'; | ||
} | ||
return 'object'; | ||
@@ -80,6 +95,9 @@ // $FlowFixMe https://github.com/facebook/flow/issues/1015 | ||
const highlight = object => chalk.red(stringify(object)); | ||
const printExpected = value => chalk.green(stringify(value)); | ||
const ensureNoExpected = (expected, matcherName) => { | ||
matcherName || (matcherName = 'This'); | ||
if (typeof expected !== 'undefined') { | ||
throw new Error(`${ matcherName } matcher does not accept any arguments`); | ||
throw new Error(`${ matcherName } matcher does not accept any arguments.`); | ||
} | ||
@@ -93,3 +111,3 @@ }; | ||
`${ matcherName } actual value should be a number. ` + | ||
`'${ typeof actual }' was passed`); | ||
`'${ typeof actual }' was passed.`); | ||
@@ -104,3 +122,3 @@ } | ||
`${ matcherName } expected value should be a number. ` + | ||
`'${ typeof expected }' was passed`); | ||
`'${ typeof expected }' was passed.`); | ||
@@ -116,7 +134,9 @@ } | ||
module.exports = { | ||
getType, | ||
stringify, | ||
ensureNoExpected, | ||
ensureActualIsNumber, | ||
ensureExpectedIsNumber, | ||
ensureNumbers }; | ||
ensureNoExpected, | ||
ensureNumbers, | ||
getType, | ||
highlight, | ||
printExpected, | ||
stringify }; |
{ | ||
"name": "jest-matcher-utils", | ||
"description": "A set of utility functions for jest-matchers and related packages", | ||
"version": "14.2.2-alpha.22bd3c33", | ||
"version": "14.3.0-alpha.d13c163e", | ||
"repository": { | ||
@@ -13,3 +13,6 @@ "type": "git", | ||
"test": "../../packages/jest-cli/bin/jest.js" | ||
}, | ||
"dependencies": { | ||
"chalk": "^1.1.3" | ||
} | ||
} |
3911
110
1
+ Addedchalk@^1.1.3
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.0(transitive)