Skip to content

Jest snapshots different classnames #595

Closed
@Ziker22

Description

@Ziker22

Everytime i run snapshot test with jest and rest-testing-library for component with tooltip inside, new css classes are generated and thus snapshot is failing. Any ideas to solve this ?

 - Snapshot
    + Received

    @@ -49,80 +49,80 @@
                >
                  XSS
                </div>
              </a>
              <div
    -           class="__react_component_tooltip t478c1214-c3a1-4e62-b8d9-bec855c08c42 place-top type-dark"
    +           class="__react_component_tooltip t6228f914-bd48-4261-96f8-0d9fbdc0096a place-top type-dark"
                data-id="tooltip"
                id="sizePicker-1001"
              >
                <style>
      
    -           .t478c1214-c3a1-4e62-b8d9-bec855c08c42 {
    +           .t6228f914-bd48-4261-96f8-0d9fbdc0096a {
            color: #fff;
            background: #222;
            border: 1px solid transparent;
                }

    -           .t478c1214-c3a1-4e62-b8d9-bec855c08c42.place-top {
    +           .t6228f914-bd48-4261-96f8-0d9fbdc0096a.place-top {
              margin-top: -10px;
          }
    -     .t478c1214-c3a1-4e62-b8d9-bec855c08c42.place-top::before {
    +     .t6228f914-bd48-4261-96f8-0d9fbdc0096a.place-top::before {
              border-top: 8px solid transparent;
          }
    -     .t478c1214-c3a1-4e62-b8d9-bec855c08c42.place-top::after {
    +     .t6228f914-bd48-4261-96f8-0d9fbdc0096a.place-top::after {
              border-left: 8px solid transparent;
              border-right: 8px solid transparent;
              bottom: -6px;
              left: 50%;
              margin-left: -8px;
              border-top-color: #222;
              border-top-style: solid;
              border-top-width: 6px;
          }

    -     .t478c1214-c3a1-4e62-b8d9-bec855c08c42.place-bottom {
    +     .t6228f914-bd48-4261-96f8-0d9fbdc0096a.place-bottom {
              margin-top: 10px;
          }
    -     .t478c1214-c3a1-4e62-b8d9-bec855c08c42.place-bottom::before {
    +     .t6228f914-bd48-4261-96f8-0d9fbdc0096a.place-bottom::before {
              border-bottom: 8px solid transparent;
          }
    -     .t478c1214-c3a1-4e62-b8d9-bec855c08c42.place-bottom::after {
    +     .t6228f914-bd48-4261-96f8-0d9fbdc0096a.place-bottom::after {
              border-left: 8px solid transparent;
              border-right: 8px solid transparent;
              top: -6px;
              left: 50%;
              margin-left: -8px;
              border-bottom-color: #222;
              border-bottom-style: solid;
              border-bottom-width: 6px;
          }

    -     .t478c1214-c3a1-4e62-b8d9-bec855c08c42.place-left {
    +     .t6228f914-bd48-4261-96f8-0d9fbdc0096a.place-left {
              margin-left: -10px;
          }
    -     .t478c1214-c3a1-4e62-b8d9-bec855c08c42.place-left::before {
    +     .t6228f914-bd48-4261-96f8-0d9fbdc0096a.place-left::before {
              border-left: 8px solid transparent;
          }
    -     .t478c1214-c3a1-4e62-b8d9-bec855c08c42.place-left::after {
    +     .t6228f914-bd48-4261-96f8-0d9fbdc0096a.place-left::after {
              border-top: 5px solid transparent;
              border-bottom: 5px solid transparent;
              right: -6px;
              top: 50%;
              margin-top: -4px;
              border-left-color: #222;
              border-left-style: solid;
              border-left-width: 6px;
          }

    -     .t478c1214-c3a1-4e62-b8d9-bec855c08c42.place-right {
    +     .t6228f914-bd48-4261-96f8-0d9fbdc0096a.place-right {
              margin-left: 10px;
          }
    -     .t478c1214-c3a1-4e62-b8d9-bec855c08c42.place-right::before {
    +     .t6228f914-bd48-4261-96f8-0d9fbdc0096a.place-right::before {
              border-right: 8px solid transparent;
          }
    -     .t478c1214-c3a1-4e62-b8d9-bec855c08c42.place-right::after {
    +     .t6228f914-bd48-4261-96f8-0d9fbdc0096a.place-right::after {
              border-top: 5px solid transparent;
              border-bottom: 5px solid transparent;
              left: -6px;
              top: 50%;
              margin-top: -4px;

      31 |     const { asFragment } = render(component);
      32 | 
    > 33 |     expect(asFragment()).toMatchSnapshot();
         |                          ^
      34 |   });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions