Skip to content

[Bug]: Using dates in expect statements with the interactions add-on causes Storybook to crash #24465

Open
@nicwells

Description

Describe the bug

Using dates in expect statements (from @storybook/jest) within interaction tests (@storybook/addon-interactions) causes storybook to crash when running in the browser, resulting in a blank screen and the following error in the console:

Uncaught TypeError: e.split is not a function or its return value is not iterable

image

The expect in the following play function causes the error for example:

  play: () => {
    const date1 = new Date(Date.UTC(2020, 8, 9));
    const date2 = new Date(Date.UTC(2020, 8, 9));
    expect(date1).toEqual(date2);
  }.

The tests pass when running in test-runner.

The error looks to originate from this line in @storybook/addon-interactions where the dates are being rendered for display in the addon-interactions panel (the split string function is being called on the date object):

const [date, time, ms] = value.split(/[T.Z]/);

The error occurs in v7.4.6 and the latest, as in the reproduction linked to below. The error did not occur in v6.5.16 which we were previously on.

To Reproduce

This error occurs in v7.4.6 of Storybook, also in the latest as in the reproduction link below. The error did not occur in v6.5.16.

Line #35 of Button.stories.js in the reproduction results in the error (i.e. white screen and error in console):

https://stackblitz.com/edit/github-pjbwb9?file=stories%2FButton.stories.js

System

No response

Additional context

No response

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status

      Empathy Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions