Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/factory-js/factory-js
ð The object generator for testing.
https://github.com/factory-js/factory-js
drizzle-orm dummy-data e2e-testing factory factory-bot fixture integration-testing jest mock playwright prisma seed seeding t3-stack test testing unit-testing vitest
Last synced: 3 days ago
JSON representation
ð The object generator for testing.
- Host: GitHub
- URL: https://github.com/factory-js/factory-js
- Owner: factory-js
- License: mit
- Created: 2024-03-12T05:31:10.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-01-06T01:45:51.000Z (16 days ago)
- Last Synced: 2025-01-11T23:10:20.498Z (10 days ago)
- Topics: drizzle-orm, dummy-data, e2e-testing, factory, factory-bot, fixture, integration-testing, jest, mock, playwright, prisma, seed, seeding, t3-stack, test, testing, unit-testing, vitest
- Language: TypeScript
- Homepage: https://factory-js.github.io/
- Size: 772 KB
- Stars: 62
- Watchers: 0
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
## Features
- â **Type Safety** - It helps prevent configuration errors and typos.
- âïļ **Highly Functional** - You can define variables, traits, and properties that depend on other properties.
- ðŠķ **Lightweight** - It is very lightweight as it does not depend on any other packages.
- ðĶ **ORM-Friendly API** - Designed to be used also with ORMs like Prisma and Drizzle.## Quick Start
1. Install FactoryJS.
```sh
pnpm add -D @factory-js/factory
```2. Define a factory and use it in your tests, database seeds, etc.
```ts
import { factory } from "@factory-js/factory";// Define the factory
const userFactory = factory.define({
props: {
firstName: () => "John",
lastName: () => "Doe",
role: () => "guest",
},
vars: {},
});describe("when a user is admin", () => {
it("returns true", async () => {
const user = await userFactory(db)
.props({ role: () => "admin" }) // Override role to admin
.build();
expect(isAdmin(user)).toBe(true);
});
});
```To learn more about FactoryJS, check the [Documentation](https://factory-js.github.io/).
## License
[MIT](https://github.com/factory-js/factory-js/blob/main/LICENSE)