
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.
@dependabit/test-utils
Advanced tools
Shared testing utilities for the monorepo using Vitest.
pnpm add -D @dependabit/test-utils
import { createMockUser, createMockEmail, createMockApiResponse } from '@dependabit/test-utils';
// Create a mock user
const user = createMockUser({ name: 'Alice' });
// Create a mock email
const email = createMockEmail({ to: 'alice@example.com' });
// Create a mock API response
const response = createMockApiResponse({ status: 201 });
import { createMockFn, spyOn } from '@dependabit/test-utils';
// Create a mock function
const mockFn = createMockFn();
mockFn.mockResolvedValue({ id: 1 });
// Spy on console
const consoleSpy = spyOn(console, 'log');
console.log('test');
expect(consoleSpy).toHaveBeenCalledWith('test');
import { createMockTimer } from '@dependabit/test-utils';
it('should handle timeouts', () => {
const timer = createMockTimer();
setTimeout(() => {
doSomething();
}, 1000);
timer.advanceTimersByTime(1000);
timer.restore();
});
import { mockFetch } from '@dependabit/test-utils';
it('should fetch data', async () => {
mockFetch('/api/users', { success: true });
const response = await fetch('/api/users');
const data = await response.json();
expect(data.success).toBe(true);
});
createMockFn(): Mock - Create a mock functionspyOn<T, K>(obj: T, method: K): Spy - Spy on object methodcreateMockTimer(): MockTimer - Create a fake timer controller
.runAll() - Run all timers.advanceTimersByTime(ms) - Advance by milliseconds.restore() - Restore real timerscreateMockUser(overrides?): User - Create a usercreateMockEmail(overrides?): Email - Create an emailcreateMockApiResponse(overrides?): ApiResponse - Create an API responsecreateMockErrorResponse(message?): ApiResponse - Create an error responsecreateMockArray<T>(count: number, factory): T[] - Create an array of mocksimport { describe, it, expect } from 'vitest';
import {
createMockUser,
createMockFn,
createMockApiResponse,
} from '@dependabit/test-utils';
describe('UserService', () => {
it('should fetch and process user', async () => {
// Arrange
const mockUser = createMockUser({ name: 'Alice' });
const mockFn = createMockFn();
mockFn.mockResolvedValue(createMockApiResponse({ user: mockUser }));
// Act
const response = await mockFn();
// Assert
expect(response.success).toBe(true);
expect(response.data.user.name).toBe('Alice');
});
});
# Run tests (if any)
pnpm --filter @dependabit/test-utils test
MIT
FAQs
Shared testing utilities for the monorepo
We found that @dependabit/test-utils demonstrated a healthy version release cadence and project activity because the last version was released less than 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.