Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add zod-fixture to mocking ecosystem #2409

Merged
merged 2 commits into from May 21, 2023

Conversation

timdeschryver
Copy link
Contributor

@timdeschryver timdeschryver commented May 6, 2023

👋 Hi, I like this library so I created the zod-fixture library based on Auto Fixure (from the .NET world).
It helps us with the generation of test data.

GitHub link: https://github.com/timdeschryver/zod-fixture
NPM link: https://www.npmjs.com/package/zod-fixture

An Example:

import { z } from 'zod';
import { createFixture } from 'zod-fixture';

const PersonSchema = z.object({
	name: z.string(),
	birthday: z.date(),
	address: z.object({
		street: z.string(),
		city: z.string(),
		state: z.string(),
	}),
	pets: z.array(z.object({ name: z.string(), breed: z.string() })),
	totalVisits: z.number(),
});

const person = createFixture(PersonSchema);

Gives you the following value for person:

{
	"name": "name-b1d5c46c-ec89-4fd5-abdf-b263ae808b84",
	"birthday": "2021-01-11T23:58:00.091Z",
	"address": {
		"street": "street-a088e991-896e-458c-bbbd-7045cd880879",
		"city": "city-0a3d2843-5b32-48f0-99e4-bdda3c6ed531",
		"state": "state-b5f857d4-ccad-46ad-94da-4524ecc672ae"
	},
	"pets": [
		{
			"name": "name-27bdfe2e-2408-4fbe-b984-c5043211ec70",
			"breed": "breed-addd4dcb-0fa3-4682-af78-af7a32e03890"
		},
		{
			"name": "name-bf785f1c-e989-4ea7-97ac-9e9a9d629b1f",
			"breed": "breed-2c177585-7a22-4bef-a50f-a00182bdfdce"
		},
		{
			"name": "name-7ac981b0-4cc8-4236-9d76-642121b9bac3",
			"breed": "breed-0e156d71-5d81-4ffd-ad51-87a2c6baeea0"
		}
	],
	"totalVisits": 372
}

@netlify
Copy link

netlify bot commented May 6, 2023

Deploy Preview for guileless-rolypoly-866f8a ready!

Name Link
🔨 Latest commit a88eac2
🔍 Latest deploy log https://app.netlify.com/sites/guileless-rolypoly-866f8a/deploys/646aad18c8484d000871ef63
😎 Deploy Preview https://deploy-preview-2409--guileless-rolypoly-866f8a.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@colinhacks colinhacks merged commit 5427565 into colinhacks:master May 21, 2023
8 checks passed
@colinhacks
Copy link
Owner

Thanks!

@timdeschryver timdeschryver deleted the patch-1 branch May 22, 2023 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants