
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.
http-error-mocker
Advanced tools
Mocking HTTP errors and network conditions for testing purposes.
npm install http-error-mocker
import { HttpErrorMocker } from 'http-error-mocker';
const mocker = new HttpErrorMocker();
// Mock a server error for specific endpoints
mocker.mock((url) => url.includes('/api/error'), {
errorType: 'server-error',
statusCode: 500,
});
// Start intercepting fetch calls
mocker.start();
// Your code that makes fetch calls
fetch('/api/error')
.then((response) => {
console.log(response.status); // 500
})
.catch((error) => {
console.error(error);
});
// Stop intercepting when done
mocker.stop();
mocker.mock((url) => url.includes('/api/error'), {
errorType: 'network-error',
});
mocker.mock((url) => url.includes('/api/error'), { errorType: 'timeout' });
mocker.mock((url) => url.includes('/api/error'), { delay: 3000 });
mocker.mock((url) => url.includes('/api/error'), { errorType: 'random' });
mocker.mock(condition: ErrorCondition, options: MockerOptions): void;
Defines a condition under which to mock an error.
mocker.start(): void;
Starts intercepting fetch calls.
mocker.stop(): void;
Stops intercepting fetch calls.
mocker.reset(): void;
Resets the mocker to its initial state.
If your environment doesn't support globalThis, the package includes a polyfill. Ensure it's imported before other code.
Contributions are welcome! Please feel free to submit a Pull Request or open an issue.
git checkout -b feature-branch)git commit -am 'Add new feature')git push origin feature-branch)If you like this project, please give it a ⭐ on GitHub! You can also follow me for more projects.
This project is licensed under the MIT License - see the LICENSE file for details.
Thanks to the developers of TypeScript, Jest, and Husky.
For any inquiries or feedback, please contact Alperen Talaslıoğlu.
FAQs
Simulate HTTP errors and network conditions for testing purposes
The npm package http-error-mocker receives a total of 1 weekly downloads. As such, http-error-mocker popularity was classified as not popular.
We found that http-error-mocker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers 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.