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 safety net preventing storybook Jest addon from throwing. #3023

Merged
merged 4 commits into from
Feb 19, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions addons/jest/src/components/Result.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ const createSubgroup = (acc, item, i, list) => {

// on last iteration inject at detected injectionpoint, and group
if (i === list.length - 1) {
// Provide a "safety net" when Jest returns a partially recognized "group"
// (recognized by acc.startTrigger but acc.endTrigger was never found) and
// it's the only group in output for a test result. In that case, acc.list
// will be empty, so return whatever was found, even if it will be unstyled
// and prevent next createSubgroup calls from throwing due to empty lists.
acc.list.push(null);

return acc.list.reduce((eacc, el, ei) => {
switch (true) {
case acc.injectionPoint === 0 && ei === 0: {
Expand Down