@kubb/plugin-faker 5.1.4 → 5.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/docs/overview.md +11 -12
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
package/docs/overview.md
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
# Faker
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Faker plugin generates one factory function per schema. Each factory returns mock data from Faker.js and accepts partial data that overrides the generated values.
|
|
4
4
|
|
|
5
|
-
`@kubb/plugin-msw` can use
|
|
5
|
+
Use the factories in tests, Storybook, and local development without a running backend. `@kubb/plugin-msw` can use them to fill mock responses.
|
|
6
6
|
|
|
7
7
|
## Setup
|
|
8
8
|
|
|
9
|
-
- Add `@kubb/plugin-ts` for the factory return types.
|
|
10
|
-
- Install `@faker-js/faker`
|
|
9
|
+
- Add `@kubb/plugin-ts` for the factory return types. Generation fails without it.
|
|
10
|
+
- Install `@faker-js/faker` v10 in the app that uses the generated code.
|
|
11
|
+
- Install `dayjs`, `moment`, or `randexp` when you pick it in `dateParser` or `regexGenerator`.
|
|
11
12
|
|
|
12
13
|
## Options worth knowing
|
|
13
14
|
|
|
14
15
|
- `seed` passes a fixed seed to `faker.seed(...)`, so every run returns the same data.
|
|
15
16
|
- `locale` sets the Faker locale. The default is `en`.
|
|
16
|
-
- `dateParser` formats date and time strings with `faker` (default), `dayjs`, or `moment`.
|
|
17
|
+
- `dateParser` formats `date` and `time` strings with `faker` (default), `dayjs`, or `moment`. `date-time` values always use Faker. `dayjs` and `moment` do not work when the adapter types a date or time as `Date`, for example with `dateType: 'date'`.
|
|
17
18
|
- `regexGenerator` turns a `pattern` into a string with `faker` (default) or `randexp`.
|
|
18
|
-
- `typeMode` sets the factory types: `inferred` (default) derives them from the generated values
|
|
19
|
+
- `typeMode` sets the factory types: `inferred` (default) derives them from the generated values, and `schema` uses the declared model type.
|
|
20
|
+
|
|
21
|
+
See [Options](https://kubb.dev/extensions/kubb-labs/plugin-faker/options) for every option and its default.
|
|
19
22
|
|
|
20
23
|
## Example
|
|
21
24
|
|
|
25
|
+
The config below generates the factories with a fixed seed.
|
|
26
|
+
|
|
22
27
|
```typescript [kubb.config.ts]
|
|
23
28
|
import { defineConfig } from 'kubb/config'
|
|
24
29
|
import { pluginTs } from '@kubb/plugin-ts'
|
|
@@ -33,9 +38,3 @@ export default defineConfig({
|
|
|
33
38
|
],
|
|
34
39
|
})
|
|
35
40
|
```
|
|
36
|
-
|
|
37
|
-
## See also
|
|
38
|
-
|
|
39
|
-
- [Faker.js](https://fakerjs.dev/)
|
|
40
|
-
- [@kubb/plugin-ts](https://kubb.dev/extensions/kubb-labs/plugin-ts)
|
|
41
|
-
- [@kubb/plugin-msw](https://kubb.dev/extensions/kubb-labs/plugin-msw)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kubb/plugin-faker",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.5",
|
|
4
4
|
"description": "Generate Faker.js mock data factories with Kubb. Produces realistic seed data and fixtures for development and testing.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"code-generation",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"registry": "https://registry.npmjs.org/"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@kubb/plugin-ts": "^5.0.
|
|
77
|
+
"@kubb/plugin-ts": "^5.0.10"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@faker-js/faker": "^10.6.0",
|