Skip to content

Latest commit

 

History

History
 
 

with-storybook

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Storybook usage

Technologies

Getting started

$ git clone https://github.com/mswjs/examples.git
$ cd examples
$ yarn
$ cd examples/with-storybook

Running locally

$ yarn storybook

Navigate to http://localhost:6006 to inspect the running Storybook.

Key points

Serve static files

In order to register the Service Worker responsible for API mocking the worker file must be available in our Storybook.

Provide the path to your public directory as a value of the -s option when running Storybook:

{
  "scripts": {
    "storybook": "start-storybook -p 6006 -s public"
  }
}

The -s public option points to the relative ./public directory that contains our Service Worker.

Start the mocking

To start the mocking before each story, create a .storybook/preview.js and call worker.start() there.