Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
@suites/unit
Advanced tools
Suites is an opinionated, flexible testing meta-framework aim at elevating the software testing experience within backend systems. By integrating a wide array of testing tools into a cohesive framework, Suites simplifies the process of creating reliable tests, thereby ensuring the development of high-quality software.
↗️ Visit Documentation ↗️ API Reference
We are excited to announce that Automock has been rebranded to Suites!
This change reflects our commitment to providing a comprehensive testing solution that caters to a broader range of testing scenarios. The core features and functionality of the framework remain the same, but with a new name and a fresh look.
🚀 Zero-Setup Mocking - Automatically generate mock objects, eliminate manual setup, reduce boilerplate code.
🔍 Type-Safe Mocks - Leverage TypeScript's power with mocks that retain the same type as real objects.
📄 Consistent Tests Structure - Test suites will follow a consistent syntax and structure, making them easier to read and maintain.
📈 Optimized Performance - By bypassing the actual DI container, unit tests run significantly faster.
🌐 Community & Support - Join a growing community of developers.
Suites suggest an alternative approach to writing unit tests for classes instead of using the traditional mocking libraries and dependency injection frameworks.
Take a look at the following example:
Consider the following UserService
and Database
classes:
export class Database {
async getUsers(): Promise<User[]> { ... }
}
export class UserService {
constructor(private database: Database) {}
async getAllUsers(): Promise<User[]> {
return this.database.getUsers();
}
}
Let's create a unit test for this class:
import { TestBed, Mocked } from '@suites/unit';
import { Database, UserService } from './user.service';
describe('User Service Unit Spec', () => {
let userService: UserService; // 🧪 Declare the unit under test
let database: Mocked<Database>; // 🎭 Declare a mocked dependency
beforeAll(async () => {
// 🚀 Create an isolated test env for the unit (under test) + auto generated mock objects
const { unit, unitRef } = await TestBed.solitary(UserService).compile();
userService = unit;
// 🔍 Retreive a dependency (mock) from the unit reference
database = unitRef.get(Database);
});
// ✅ Test test test
test('should return users from the database', async () => {
const mockUsers: User[] = [{ id: 1, name: 'John' }, { id: 2, name: 'Jane' }];
database.getUsers.mockResolvedValue(mockUsers);
const users = await userService.getAllUsers();
expect(database.getUsers).toHaveBeenCalled();
expect(users).toEqual(mockUsers);
});
});
With the use of the TestBed
, an instance of the UserService
class can be created with mock objects automatically
generated for its dependencies. During the test, we have direct access to the automatically generated mock object for
the Database
dependency (database).
↗️ For more comprehensive examples
First, install Suites' core package:
$ npm i -D @suites/unit
Then, to fully integrate Suites into your mocking and dependency injection frameworks, install the corresponding adapters for your project. For example, to use Suites with Jest and NestJS you would run (alongside the core package):
$ npm i -D @suites/doubles.jest @suites/di.nestjs
Suites will automatically detect the installed adapters and configure itself accordingly.
DI Framework | Package Name |
---|---|
NestJS | @suites/di.nestjs |
Inversify | @suites/di.inversify |
TSyringe | Soon! |
DI Framework | Package Name |
---|---|
Jest | @suites/doubles.jest |
Sinon | @suites/doubles.sinon |
Vitest | @suites/doubles.vitest |
Bun | Soon! |
Deno | Soon! |
Distributed under the Apache (Apache-2.0) License. See LICENSE
for more information.
FAQs
Unknown package
The npm package @suites/unit receives a total of 5,380 weekly downloads. As such, @suites/unit popularity was classified as popular.
We found that @suites/unit 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.