@chehsunliu/seeder-redis
v0.8.1
Published
The Redis implementation for Seeder.js
Downloads
461
Readme
Seeder.js / Redis
The Redis implementation for Seeder.js.
Getting Started
Install Seeder.js:
npm install -D @chehsunliu/seeder @chehsunliu/seeder-redis
Use Docker Compose to serve a Redis server:
services:
redis:
image: redis:7-alpine
restart: always
ports:
- "127.0.0.1:6379:6379"
Configure the seeders in setup.ts
, which should be loaded in Jest setupFilesAfterEnv
or in Vitest setupFiles
:
import { seederManager } from "@chehsunliu/seeder";
import { RedisSeeder } from "@chehsunliu/seeder-redis";
seederManager.configure([
new RedisSeeder({
url: "redis://127.0.0.1:6379",
}),
]);
afterAll(async () => {
await seederManager.release();
});
Invoke the seeders in tests:
import { seederManager } from "@chehsunliu/seeder";
beforeEach(async () => {
await seederManager.truncate();
await seederManager.seed(path.join(__dirname, "data"));
});
test("blah blah blah", () => {
// Cache should be clean.
});