
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-stubber-upgrade
Advanced tools
A simple but useful stubbing solution for React. This will work with any container library whether it's Redux, React Komposer or with any React Component.
Read this article for an introduction: Stubbing React Containers for Testing
First of all, we need to wrap React classes we need to stub with the mayBeStubbed function. See:
import React from 'react';
// compose if our container building library.
import compose from './compose';
import { mayBeStubbed } from 'react-stubber';
export const CommentList = () => (
<ul>
</ul>
);
CommentList.displayName = 'CommentList';
export const CommentListContainer = mayBeStubbed(compose(CommentList));
Then we can use the CommentListContainer anywhere we need.
So, let's use the above CommentListContainer inside another Component called Post.
export const Post = (post) => (
<div style={style}>
<h1>{post.title}</h1>
<p>{post.text}</p>
<hr />
<h3>Comments</h3>
<CommentListContainer postId={post.id} />
</div>
);
In order to do isolated testing, first make sure we are in the stubbing mode.
We need to do this, before importing any React component. This is something you could do when doing the test setup or in the React Storybook config file.
import { setStubbingMode } from 'react-stubber';
setStubbingMode(true);
Then when we render Post we will get something like this:

We can also stub this component with a custom component we like. This is how we do that. You need to do this before using the Post component.
(The test file or storybook story file is a good place for this).
import { stub } from 'react-stubber';
stub(CommentListContainer3, (props) => (
<div>Comments for postId: {props.postId}</div>
));
Then once rendered it will looks like this.

FAQs
Simple but useful stubbing solution React
We found that react-stubber-upgrade 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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.