-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expect: Highlight substring differences when matcher fails, part 1 #8448
Conversation
I am not sure if the Here is 'use strict';
function _defineProperty(obj, key, value) {
if (key in obj) {
Object.defineProperty(obj, key, {
value: value,
enumerable: true,
configurable: true,
writable: true
});
} else {
obj[key] = value;
}
return obj;
} |
Oh my god, I'm so excited! 😀
It should be, we had the same thing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So good!
Would it make sense for the vendored file to live in |
And yes, rendering some explicit newline character would be awesome, like ava does |
Codecov Report
@@ Coverage Diff @@
## master #8448 +/- ##
==========================================
+ Coverage 62.32% 62.78% +0.45%
==========================================
Files 266 267 +1
Lines 10734 11021 +287
Branches 2615 2674 +59
==========================================
+ Hits 6690 6919 +229
- Misses 3461 3497 +36
- Partials 583 605 +22
Continue to review full report at Codecov.
|
@SimenB it’s related to your #8085 (comment) although
I think the problem is https://github.com/facebook/jest/blob/master/scripts/build.js#L122-L125
Does it make sense to swap the logic to avoid double negative in if (
micromatch.isMatch(file, JS_FILES_PATTERN) ||
(micromatch.isMatch(file, TS_FILES_PATTERN) &&
!micromatch.isMatch(D_TS_FILES_PATTERN))
) {
// compile file
} else {
// copy file
} |
They should work - we deleted some in #8294 which worked fine previously. It's the tsc run that should copy it, not babel. Try to run |
Good question about packaging. The reason to keep
|
@SimenB this is making me learn more about Jest build scripts and TypeScript config :)
Compiling as |
Solved by renaming as
Finding that tricky Question: in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wooooo, this is super awesome ❤️
Mandatory (TSC won't ever look at the folder if it's not referenced) - if it works without, it's probably "lucky" because it's also referenced from ´jest-diff` |
While writing tests for multi-line strings, I found an edge case of comparison to empty string Highlighting the non-empty string at left seems less helpful than no highlight at right: Added a test and then updated it after adding the missing condition For the test where I found the problem, do you prefer the report at left or right, and why? |
I prefer the right one, since it's explicit about the value of "Received". The left one looks like a bug due to it missing received |
Residue
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still LGTM after the tweaks, feel free to merge if you have nothing more to include here in mind ;)
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Fixes #6881 although space and no-break space still look the same
If positive assertion fails with one-line strings for both expected and received:
Then if character difference with “semantic cleanup” has any common substring:
Display changes similar to Changed Files on GitHub:
Else if no common substring, display without any inverse colors
Build:
EDIT: The following list is generally but not specifically true, because
printDiffOrStringify
moved tojest-matcher-utils
packagepackages/expect/build-es5/index.js
is about 1M bytes, increased < 40K bytesdiff-sequences
dependency, it was already inbuild-es5
bundleexpect/tsconfig.json
see expect: Highlight substring differences when matcher fails, part 1 #8448 (comment)review ofpackages/expect/src/cleanupSemantic.d.ts
is especially welcomesee expect: Highlight substring differences when matcher fails, part 1 #8448 (comment) aboutpackages/expect/build/cleanupSemantic.d.js
License:
Does anyone know if I have correctly handled code with Apache License, Version 2.0?
cleanupSemantic.js
.eslintignore
and.prettierignore
scripts/checkCopyrightHeaders.js
Residue:
toThrow(object)
which does not call the same helper functiontoContain
,toMatch
, ortoThrow
[EDIT: and found its effectiveness to be disappointingly hit or miss]Test plan
EDIT: Updated a distantly related snapshot test, see see #8448 (comment)
Existing tests pass, because they have no common substring with “semantic cleanup”
Added 1 snapshot each:
toBe
and then added a second test for empty string, see expect: Highlight substring differences when matcher fails, part 1 #8448 (comment)toEqual
toHaveProperty(path, value)
toStrictEqual
See also pictures in following comment