From d3e0a3aaf33dd0134a2c5296db8b6ca43cab968e Mon Sep 17 00:00:00 2001 From: Ivan Babak Date: Fri, 8 Jun 2018 05:18:22 -0700 Subject: [PATCH] Fix jest/matchers/toWarnDev expected, actual order for jest-diff (#12285) (#12288) `toWarnDev` calls `jestDiff(a, b)` which calls `diffStrings(a, b)` where by default `a` is annotated as `'Expected'` (green), `b` as `'Received'` (red). So the first argument passed into `jestDiff` should be the expected message, the second should be the actual message. It was vice versa previously. - https://github.com/facebook/jest/blob/457776b2889a9be1ce8a2c636a23417264a98d99/packages/jest-diff/src/index.js#L54 - https://github.com/facebook/jest/blob/457776b2889a9be1ce8a2c636a23417264a98d99/packages/jest-diff/src/index.js#L93 - https://github.com/facebook/jest/blob/457776b2889a9be1ce8a2c636a23417264a98d99/packages/jest-diff/src/diff_strings.js#L249-L251 --- scripts/jest/matchers/toWarnDev.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/jest/matchers/toWarnDev.js b/scripts/jest/matchers/toWarnDev.js index f8ae0be174..c8e17d794c 100644 --- a/scripts/jest/matchers/toWarnDev.js +++ b/scripts/jest/matchers/toWarnDev.js @@ -49,11 +49,11 @@ const createMatcherFor = consoleMethod => } else if (expectedMessages.length === 1) { errorMessage = 'Unexpected warning recorded: ' + - jestDiff(normalizedMessage, expectedMessages[0]); + jestDiff(expectedMessages[0], normalizedMessage); } else { errorMessage = 'Unexpected warning recorded: ' + - jestDiff([normalizedMessage], expectedMessages); + jestDiff(expectedMessages, [normalizedMessage]); } // Record the call stack for unexpected warnings.