Skip to content
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

Merged
merged 7 commits into from
Feb 18, 2018
Merged

Added "key" prop to list items inside test failure message. #2867

merged 7 commits into from
Feb 18, 2018

Conversation

tniezg
Copy link
Contributor

@tniezg tniezg commented Jan 29, 2018

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.

@Hypnosphi Hypnosphi added bug addon: jest patch:yes Bugfix & documentation PR that need to be picked to main branch labels Jan 29, 2018
@@ -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>)}
Copy link
Member

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

Copy link
Contributor Author

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
Copy link

codecov bot commented Feb 2, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@8e4b520). Click here to learn what that means.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #2867   +/-   ##
=========================================
  Coverage          ?   37.37%           
=========================================
  Files             ?      426           
  Lines             ?     9157           
  Branches          ?      848           
=========================================
  Hits              ?     3422           
  Misses            ?     5234           
  Partials          ?      501
Impacted Files Coverage Δ
addons/jest/src/components/Result.js 0% <0%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8e4b520...8bf259c. Read the comment docs.

@Hypnosphi Hypnosphi merged commit 343a695 into storybookjs:master Feb 18, 2018
@tniezg tniezg deleted the test-fail-message-keys-fix branch February 19, 2018 14:06
shilman pushed a commit that referenced this pull request Feb 21, 2018
Added "key" prop to list items inside test failure message.
@Hypnosphi Hypnosphi added patch:done Patch/release PRs already cherry-picked to main/release branch and removed patch:done Patch/release PRs already cherry-picked to main/release branch labels Mar 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addon: jest bug patch:done Patch/release PRs already cherry-picked to main/release branch patch:yes Bugfix & documentation PR that need to be picked to main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants