Socket
Socket
Sign inDemoInstall

jest-diff

Package Overview
Dependencies
Maintainers
2
Versions
230
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-diff - npm Package Compare versions

Comparing version 20.0.3 to 20.1.0-alpha.1

build/diff_strings.js

33

build/constants.js

@@ -1,19 +0,22 @@

'use strict'; /**
* Copyright (c) 2014, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/
'use strict';
const chalk = require('chalk');
exports.NO_DIFF_MESSAGE = chalk.dim(
'Compared values have no visual difference.');
exports.SIMILAR_MESSAGE = chalk.dim(
'Compared values serialize to the same structure.\n' +
'Printing internal object structure without calling `toJSON` instead.');
var _chalk = require('chalk');var _chalk2 = _interopRequireDefault(_chalk);function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };}
exports.NO_DIFF_MESSAGE = _chalk2.default.dim(
'Compared values have no visual difference.'); /**
* Copyright (c) 2014, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/exports.SIMILAR_MESSAGE = _chalk2.default.dim('Compared values serialize to the same structure.\n' + 'Printing internal object structure without calling `toJSON` instead.');

@@ -1,2 +0,2 @@

'use strict';var _require$plugins =
'use strict';

@@ -13,22 +13,21 @@

var _prettyFormat = require('pretty-format');var _prettyFormat2 = _interopRequireDefault(_prettyFormat);
var _chalk = require('chalk');var _chalk2 = _interopRequireDefault(_chalk);
var _jestGetType = require('jest-get-type');var _jestGetType2 = _interopRequireDefault(_jestGetType);
var _diff_strings = require('./diff_strings');var _diff_strings2 = _interopRequireDefault(_diff_strings);
var _constants = require('./constants');function _interopRequireDefault(obj) {return obj && obj.__esModule ? obj : { default: obj };} /**
* Copyright (c) 2014, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/var _prettyFormat$plugins = _prettyFormat2.default.plugins;const AsymmetricMatcher = _prettyFormat$plugins.AsymmetricMatcher,HTMLElement = _prettyFormat$plugins.HTMLElement,Immutable = _prettyFormat$plugins.Immutable,ReactElement = _prettyFormat$plugins.ReactElement,ReactTestComponent = _prettyFormat$plugins.ReactTestComponent;
require('pretty-format').plugins;const ReactElement = _require$plugins.ReactElement,ReactTestComponent = _require$plugins.ReactTestComponent,AsymmetricMatcher = _require$plugins.AsymmetricMatcher,HTMLElement = _require$plugins.HTMLElement,Immutable = _require$plugins.Immutable; /**
* Copyright (c) 2014, Facebook, Inc. All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*
*/const chalk = require('chalk');var _require = require('jest-matcher-utils');const getType = _require.getType;const prettyFormat = require('pretty-format');const diffStrings = require('./diffStrings');var _require2 = require('./constants');const NO_DIFF_MESSAGE = _require2.NO_DIFF_MESSAGE,SIMILAR_MESSAGE = _require2.SIMILAR_MESSAGE;
const PLUGINS = [
ReactTestComponent,
ReactElement,
AsymmetricMatcher,
HTMLElement].
HTMLElement,
AsymmetricMatcher].
concat(Immutable);

@@ -48,6 +47,6 @@ const FORMAT_OPTIONS = {

if (a === b) {
return NO_DIFF_MESSAGE;
return _constants.NO_DIFF_MESSAGE;
}
const aType = getType(a);
const aType = (0, _jestGetType2.default)(a);
let expectedType = aType;

@@ -70,7 +69,7 @@ let omitDifference = false;

if (expectedType !== getType(b)) {
if (expectedType !== (0, _jestGetType2.default)(b)) {
return (
' Comparing two different types of values.' +
` Expected ${chalk.green(expectedType)} but ` +
`received ${chalk.red(getType(b))}.`);
` Expected ${_chalk2.default.green(expectedType)} but ` +
`received ${_chalk2.default.red((0, _jestGetType2.default)(b))}.`);

@@ -87,3 +86,3 @@ }

if (multiline) {
return diffStrings(String(a), String(b), options);
return (0, _diff_strings2.default)(String(a), String(b), options);
}

@@ -116,5 +115,5 @@ return null;

try {
diffMessage = diffStrings(
prettyFormat(a, FORMAT_OPTIONS),
prettyFormat(b, FORMAT_OPTIONS),
diffMessage = (0, _diff_strings2.default)(
(0, _prettyFormat2.default)(a, FORMAT_OPTIONS),
(0, _prettyFormat2.default)(b, FORMAT_OPTIONS),
options);

@@ -128,10 +127,10 @@

// without calling `toJSON`. It's also possible that toJSON might throw.
if (!diffMessage || diffMessage === NO_DIFF_MESSAGE) {
diffMessage = diffStrings(
prettyFormat(a, FALLBACK_FORMAT_OPTIONS),
prettyFormat(b, FALLBACK_FORMAT_OPTIONS),
if (!diffMessage || diffMessage === _constants.NO_DIFF_MESSAGE) {
diffMessage = (0, _diff_strings2.default)(
(0, _prettyFormat2.default)(a, FALLBACK_FORMAT_OPTIONS),
(0, _prettyFormat2.default)(b, FALLBACK_FORMAT_OPTIONS),
options);
if (diffMessage !== NO_DIFF_MESSAGE && !hasThrown) {
diffMessage = SIMILAR_MESSAGE + '\n\n' + diffMessage;
if (diffMessage !== _constants.NO_DIFF_MESSAGE && !hasThrown) {
diffMessage = _constants.SIMILAR_MESSAGE + '\n\n' + diffMessage;
}

@@ -138,0 +137,0 @@ }

{
"name": "jest-diff",
"version": "20.0.3",
"version": "20.1.0-alpha.1",
"repository": {

@@ -10,9 +10,9 @@ "type": "git",

"main": "build/index.js",
"browser": "build-es5/index.js",
"dependencies": {
"chalk": "^1.1.3",
"diff": "^3.2.0",
"jest-matcher-utils": "^20.0.3",
"pretty-format": "^20.0.3"
"jest-get-type": "^20.1.0-alpha.1",
"jest-matcher-utils": "^20.1.0-alpha.1",
"pretty-format": "^20.1.0-alpha.1"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc