-
-
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
Improves the terse messages in jest-editor #3615
Conversation
@@ -1,5 +1,5 @@ | |||
{ | |||
"jest.pathToJest": "npm run jest --", | |||
"jest.pathToJest": "yarn jest --", |
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.
if (string.includes("New snapshot was not written")) { | ||
return "New snapshot is ready to write" | ||
} | ||
|
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.
These are some special cases, you can't show anything of value for these two cases in a tweet-sized message, so I've added them as special cases.
.replace('Difference:', ' Difference:'); | ||
.replace(/\s\s+/g, ' ') | ||
.replace('Received:', ', Received:') | ||
.split('Difference:')[0]; |
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.
message = "Expected value to be truthy, instead received null" | ||
testName = "truthy" | ||
expect(terseForTest(testName).terseMessage).toEqual(message) | ||
}) |
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.
didn't think it was worth having all the work split across multiple it
s - it slows down the tests needlessly with all the JSON parsing + string manipulation.
@@ -108,15 +108,24 @@ module.exports = class TestReconciler { | |||
|
|||
// Do everything we can to try make a one-liner from the error report | |||
sanitizeShortErrorMessage(string: string): string { | |||
if (string.includes("does not match stored snapshot")) { |
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.
We need more structured data around this so that it won't break going forward.
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.
I had a look at this, but the way things are pieced together is like this:
There is a this test which incidentally covers this case, I could add comments to it?
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.
Yeah, adding a comment for now would be very nice.
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.
Cool - added
@@ -52,3 +52,41 @@ Expected value to be falsy, instead received | |||
}); | |||
}); | |||
}); | |||
|
|||
describe('Terse Messages', () => { | |||
it("handles shrinking a snapshot message", () => { |
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.
single quote please (did you run prettier on this file?)
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.
It looks like it wasn't set up to run, I've fixed that - good catch.
…_terse_messages
…the error it is implicity relying on
@orta mind making sure that |
…the error it is implicity relying on
5c1e572
to
8359083
Compare
🥗 |
* Improves the terse messages in jest-editor * Adds a note about wording for jest-editor inside a test that matches the error it is implicity relying on * Adds a note about wording for jest-editor inside a test that matches the error it is implicity relying on
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
The terse messages sometimes were not terse, as they're built for showing inline they definitely needed cutting down to size in some places. So I made a list of some common failing assertions and added some tests against each of them.
I turned the results of this into a fixture, and started working from that.
Test plan
This has unit tests 👍