-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Added "key" prop to list items inside test failure message. #2867
Added "key" prop to list items inside test failure message. #2867
Conversation
addons/jest/src/components/Result.js
Outdated
@@ -35,7 +35,7 @@ const StackTrace = glamorous(({ trace, className }) => ( | |||
.join('') | |||
.trim() | |||
.split(/\n/) | |||
.map(i => <div>{i.trim()}</div>)} | |||
.map(traceLine, traceLineIndex => <div key={traceLineIndex}>{traceLine.trim()}</div>)} |
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.
Is there a chance we can use something other than index as a key? Otherwise, I think you can suppress the corresponding eslint rule for this line
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'd like to use something else for the key prop but can't find any reasonable alternatives. I will add the ESLint rule.
Codecov Report
@@ Coverage Diff @@
## master #2867 +/- ##
=========================================
Coverage ? 37.37%
=========================================
Files ? 426
Lines ? 9157
Branches ? 848
=========================================
Hits ? 3422
Misses ? 5234
Partials ? 501
Continue to review full report at Codecov.
|
Added "key" prop to list items inside test failure message.
Issue:
React complains about missing "key" prop in lists displaying a failed Jest test.
What I did
Added "key" prop equal the list element's index on the list.
How to test
Create a failing Jest test, let jest output results to a JSON file and have that file load be loaded by Storybook's Jest addon.
Is this testable with jest or storyshots?
Jest's output JSON file containing information about a failed test is required.
Does this need a new example in the kitchen sink apps?
No
Does this need an update to the documentation?
No
If your answer is yes to any of these, please make sure to include it in your PR.