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.
mockingbird
Advanced tools
Super Simple, Yet Powerful, TypeScript Library for Creating Mocks. Mockingbird allows you to create class mocks like a breeze with a simple yet powerful @Mock decorator
npm i -D mockingbird
yarn add -D mockingbird
A lot of times you find yourself “preparing” some dummy data for your tests that has to make sense for a specific test case(s) and is manipulated often. Some developers are preparing JSON files, others create a long verbose object in the test file itself, but the outcome always contains some fake data inside (or even a snapshot from an external API).
This is what Mockingbird aims to solve! It suggests two ways of creating mocks for your entities/models classes, thus, creating one uniform way to manage mocks (whether you are working alone or with your team), your dev experience will improve, and you won’t have to deal with this messy setup at all!
Here is the simplest usage of Mockingbird:
// Could be interface as well
class BirdEntity {
name: string;
birthday: Date;
goodPoints: number;
}
import { Mock, MockFactory } from 'mockingbird';
// BirdEntity could be an interface or a class
class BirdEntityMock implements BirdEntity {
@Mock(faker => faker.name.firstName())
name!: string;
@Mock()
birthday!: Date; // Will generate a recent date
@Mock()
goodPoints!: number; // Will generate a random number
}
const oneBird = MockFactory(BirdEntityMock).one();
const lotsOfBirds = MockFactory(BirdEntityMock).many(3);
Jump to the full documentation and explore the full API
There's also an example, you can find it under the sample folder
Jump to the REPL Playground where you can see Mockingbird in action!
Creating mocks for your tests (sometimes called "fixtures") can be a tedious and cumbersome process usually done manually.
We came up with a simple yet super convenient solution: all you have to do to get mocks out of the box is to decorate your classes (whether it's an entity, or a model representing the database layer) and generate simple or complex mocks.
Mockingbird offers two different ways for preparing mocks; The first one (as we call it), is the TypeScript way which requires decorating existing (or duplicate) classes. The second way is to use Mockingbird's functionality directly
faker.js
?faker.js
it's a library which is used to "generate massive amounts of fake data in the browser and Node".
Mockingbird uses faker.js
under the hood, making it possible to enjoy its rich database, and thereby allows
to create mocks that are meaningful like email, first name, address and many more.
Distributed under the MIT License. See LICENSE
for more information.
FAQs
Super Simple, Yet Powerful, TypeScript Library for Creating Mocks. Mockingbird allows you to create class mocks like a breeze with a simple yet powerful @Mock decorator
We found that mockingbird 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.
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.