Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
OrganizationAdvent CalendarQiitadon (β)
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

【Storybook】`storyshots-puppeteer` で異なるデバイスのビジュアルスナップショットを撮る方法

More than 1 year has passed since last update.

Storybook に storyshots-puppeteer を導入した後、異なるデバイスのビジュアルスナップショットを撮れるようにしたいと思い、下記のように書き換えました。

import initStoryshots from '@storybook/addon-storyshots'
import { imageSnapshot } from '@storybook/addon-storyshots-puppeteer'
import pupDevices from 'puppeteer/DeviceDescriptors';

const supportedDevices = new Set(['iPad', 'iPhone 5', 'iPhone 6', 'iPhone 7 Plus'])

initStoryshots({ suite: 'Image storyshots: PC', test: imageSnapshot() })

function createCustomizePage(pupDevice) {
  return function(page) {
    return page.emulate(pupDevice);

for (let supportedDevice of supportedDevices) {
  const pupDevice = pupDevices[supportedDevice];

  if (!pupDevice) {

  const customizePage = createCustomizePage(pupDevice);

    suite: `Image storyshots: ${pupDevice.name}`,
    test: imageSnapshot({
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away