Cookie

Storybook addon for setting document.cookie

View on GithubNew to Storybook?Get started

Features

  • Set document.cookie for each Storybook.

Live demo

Installing and Setup

Install addon

With npm:

npm i storybook-addon-cookie -D

Or with yarn:

yarn add storybook-addon-cookie -D

Configure the addon

Provide cookieDecorator to Storybook by editing ./storybook/preview.js.

import { cookieDecorator } from 'storybook-addon-cookie';

export const decorators = [cookieDecorator];

Usage

You can pass cookie object into cookie parameter.

export default {
  component: Example,
  title: 'Example',
}

const Template = () => <Example/>

export const WithCookie = Template.bind({});
WithCookie.parameters = {
  cookie: {
    test: 'TEST!',
  }
}

export const WithOutCookie = Template.bind({});

Each Story has independent cookie.