
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.
@luispablo/test-helpers
Advanced tools
Some small and simple helpers for my unit tests
How to use
import { DispatchMock } from "@luispablo/test-helpers";
...
const expectedActions = ["set item", "remove item"]; // The redux actions you want dispatched
const dispatch = DispatchMock(assert, expectedActions, true);
// the first param is the tape assert Object
// the last param is optional, if set to true makes an assert.comment with the actions dispatched
This component is a function that works as the new fetch API function, so when your code calls it as fetcher("url") it will return a promise that resolves or reject, based on the params you provide.
So, first do
import { FetcherMock } from "@luispablo/test-helpers";
And then, for an HTTP 200 response with a JSON body do
const fetcher = FetcherMock({ json: { name: "Tom" } });
So, fetch("anyURL") will resolve a response with a json() function that returns { name: "Tom" }.
To resolve the promise, but with different HTTP code do
const fetcher = FetcherMock({ status: 404 });
This will still resolve when you invoke it, but giving you a response object with the status property in 404.
And finally, if you want it to reject (as in a network error) do
const fetcher = FetcherMock({ error: { code: 1, message: "Network error" } });
This will fall into the catch part of the promise, with an error param with code 1 and the message shown above.
This is a HTML 5 window local storage mock, to use in your tests. Just do:
import { LocalStorageMock } from "@luispablo/test-helpers";
...
// and then
const storage = LocalStorageMock();
// and you're done!
FAQs
Some small and simple helpers for my unit tests
The npm package @luispablo/test-helpers receives a total of 5 weekly downloads. As such, @luispablo/test-helpers popularity was classified as not popular.
We found that @luispablo/test-helpers 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.