
Research
Malicious fezbox npm Package Steals Browser Passwords from Cookies via Innovative QR Code Steganographic Technique
A malicious package uses a QR code as steganography in an innovative technique.
storybook-addon-manual-mocks
Advanced tools
Mock your imports in the same way as Jest Manual Mocks do
The Storybook Manual Mocks addon can be used to Mocking your imports as Manual Mocks in Jest
Install this addon by adding the storybook-addon-manual-mocks
dependency:
yarn add -D storybook-addon-manual-mocks
# or
npm install --save-dev storybook-addon-manual-mocks
within .storybook/main.js
:
module.exports = {
addons: [
{
name: "storybook-addon-manual-mocks",
options: {
mocksFolder: "__mocks__",
}
}
],
};
vite
configmodule.exports = {
addons: [
{
name: "storybook-addon-manual-mocks/vite",
options: {
mocksFolder: "__mocks__",
}
}
],
};
webpack
configmodule.exports = {
addons: [
{
name: "storybook-addon-manual-mocks/webpack",
options: {
mocksFolder: "__mocks__",
}
}
],
};
options
Name | Type | Default | Description |
---|---|---|---|
mocksFolder | string | "__mocks__" | Custom mocks folder |
You can extract you server querying from components to hooks and mock those files
MyComponent
├── __mocks__
│ └── MyComponent.hooks.js
├── MyComponent.component.js
├── MyComponent.stories.js
├── MyComponent.hooks.js
└── index.js
When you will import MyComponent.hooks
in MyComponent.component.js
, file from __mocks__
directory will be used instead
import { useSomeData } from 'MyComponent.hooks';
// it will import mock under the hood '__mocks__/MyComponent.hooks';
This addon works only with relative imports(./
or ../
) for example
// ✅ this CAN be mocked
import { useSomeData } from './MyComponent.hooks';
// ✅ this CAN be mocked
import { useSomeData } from '../MyComppnent/MyComponent.hooks';
// ⛔️ this CAN'T be mocked
import { useSomeData } from '@monorepo/components/MyComponent/MyComponent.hooks';
// ✅ this CAN be mocked
// Because inside the package, MyComponent.hooks was imported relatively
// `./MyComponent.hooks` by `MyComponent/index.js`, so it will be mocked correctly
import { useSomeData } from '@monorepo/components';
FAQs
Mock your imports in the same way as Jest Manual Mocks do
We found that storybook-addon-manual-mocks demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
Application Security
/Research
/Security News
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.