
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@drakensoftware/magicmock
Advanced tools
MagicMock is like a smart recording device for your software tests. Here's what it does in plain terms:
First Test Run
Future Test Runs
Example: If your app fetches weather data, MagicMock:
MagicMock is currently in BETA
⚠️ API may change in future versions
⚠️ Some edge cases not yet handled
⚠️ Use with caution in critical projects
npm install magic-mock --save-dev
// test.spec.ts
import { mockFunction } from 'magic-mock';
import { fetchData } from './api';
// Create mock
const mockedFetch = mockFunction(this, 'fetchData', fetchData);
test('returns valid data', async () => {
const result = await mockedFetch('https://api.example.com');
expect(result).toMatchSnapshot();
});
__magicMock__
directory📷 Created new snapshot for 'fetchData'
✨ Using snapshot for 'fetchData'
Initial Test Run
.snap
file in __magicMock__
Future Test Runs
secret()
to mask sensitive values
import { secret } from 'magic-mock';
const secureFetch = mockFunction(
this,
'authRequest',
(token: string) => secret(token, 'API_TOKEN')
);
Embed MagicMock in your library for seamless user experience:
// your-library.ts
import { mockFunction } from 'magic-mock';
export class DataService {
constructor(private fetcher: typeof fetch) {}
async getData(url: string) {
const safeFetch = mockFunction(this, 'safeFetch', this.fetcher);
return safeFetch(url);
}
}
User Benefits:
Mock third-party APIs not using MagicMock:
// tests/api.spec.ts
import { externalSDK } from 'third-party';
import { mockFunction } from 'magic-mock';
const mockedSDK = mockFunction(
this,
'thirdPartySDK',
externalSDK.initialize
);
test('handles SDK initialization', async () => {
const instance = await mockedSDK({ apiKey: 'test123' });
expect(instance.status).toBe('active');
});
import { mockClass } from 'magic-mock';
class PaymentProcessor {
async charge(amount: number) { /* ... */ }
}
const processor = mockClass(new PaymentProcessor(), 'PaymentGateway');
import { callMocked } from 'magic-mock';
test('complex test scenario', async () => {
const result = await callMocked(
complexWorkflow,
'custom-scenario-123'
);
// Custom assertions
});
Commit Snapshots
__magicMock__/
├── serviceA/
└── serviceB/
Snapshot Maintenance
Selective Mocking
// Disable for specific tests
beforeAll(() => {
process.env.DISABLE_MM = 'true';
});
Variable | Default | Description |
---|---|---|
DISABLE_MM | false | Disable all mocking behavior |
project-root/
├── __magicMock__/
│ ├── serviceA/
│ │ └── testDoSomething
│ │ ├── 0
│ │ └── 1
│ └── serviceB/
│ └── testDoAnotherThing
│ ├── 0
│ ├── 1
│ └── 2
├── src/
└── tests/
Q: How does MagicMock differ from Jest's built-in mocking?
A: Provides automatic snapshot-based mocking without manual mocking implementation.
Q: Can I use it with other test runners?
A: Currently optimized for Jest. Community plugins may enable other runners.
Q: How to handle changing API responses?
A: Delete relevant files and re-run tests to regenerate.
[](https://github.com/drakensoftware/magicmock)
Upgrade Your Jest Testing - MagicMock eliminates manual mock maintenance while ensuring test consistency. Start focusing on what matters - your test logic! 🚀
FAQs
Create your mocks automagically
The npm package @drakensoftware/magicmock receives a total of 3 weekly downloads. As such, @drakensoftware/magicmock popularity was classified as not popular.
We found that @drakensoftware/magicmock demonstrated a healthy version release cadence and project activity because the last version was released less than 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
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.