Skip to content

Snapshots are tiny / being resized #500

@joshvillbrandt

Description

@joshvillbrandt

Hello!

I have a few full-page tests with a storybook viewport typically set to 2160 x 1440 pixels. The subsequent image that is generated on my filesystem is only 720 x 480 pixels, however. This is exactly a 3x reduction of the original value in both dimensions.

I am specifying the view port similar to this:

import { INITIAL_VIEWPORTS } from "storybook/viewport";

export const Default: Story = {
  tags: ["snapshot"],
  parameters: {
    viewport: {
      options: {
        ...INITIAL_VIEWPORTS,
        test: {
          name: "Test",
          styles: {
            width: `1440px`,
            height: `2160px`,
          },
        },
      },
      defaultViewport: "test",
    },
  },
  args: {},
};

I'm hoping someone can help me figure out why this image is being reduced in size and how I can prevent it.

Things I've tried:

  1. Increasing the viewport size as implemented above yields similarly resized images. For example, bumping this up to 2880 x 1920 still yields a 720 x 480 image, which is a 4x reduction in each dimension. Varying the height and width independently does yield different final image dimensions that are similarly small.
  2. I've tried setting the browser viewport directly in my vitest browser configuration.
  3. I've poured over the source code in the repo without luck. The compare_image.ts file seems to be the most interesting of the bunch, but I can't detect any explicit resizing commands besides matching the baseline and results images.

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