New
Community Showcase #5Visual test with Chromatic
Star79,046
Back to integrations
Add your integration
Categories
  • ⭐️ Popular
  • 🧩 Essentials
  • 🛠 Code
  • ⚡️ Data & state
  • ✅ Test
  • 💅 Style
  • 🎨 Design
  • ⚙️ Appearance
  • 🗄 Organize
How to install addons Create an addon
jest-knobs
A library for mocking @storybook/addon-knobs in Jest
npm install jest-knobs
Last updated about 3 years ago
0
Downloads per week
Readme View on GitHub

jest-knobs

Usage

First, install jest-knobs with npm:

npm i -D jest-knobs

In order to install the mocks, import jest-knobs into your Jest setup file or include jest-knobs itself as a setup file in your setupFilesAfterEnv

module.exports = {
  setupFilesAfterEnv: ["jest-knobs"]
};

In your tests, you can import jest-knobs and call mockKnobValues to change the knob values for a single test.

import knobs from "jest-knobs";

knobs.mockKnobValues({
  "knob name": "value"
});

// render the story after mocking the knob values
render(someStoryWithKnobs())
Join the community
6,200 developers and counting
WhyWhy StorybookComponent-driven UI
Open source software
Storybook

Maintained by
Chromatic
Special thanks to Netlify and CircleCI