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

Suggestion: add ability of data persistence in mock factory #37

Closed
omermorad opened this issue Jul 11, 2021 · 0 comments
Closed

Suggestion: add ability of data persistence in mock factory #37

omermorad opened this issue Jul 11, 2021 · 0 comments
Assignees
Labels
enhancement 🎉 New feature or request

Comments

@omermorad
Copy link
Owner

Today, the common use of Mockingbird looks like this

MockFactory.create<User>(UserEntity, { count: 3 });

The data is often used for seeding a database or simply just to generate fixtures for integration tests.

I suggest adding the option to persist the data into a file, exactly like Jest is doing with Snapshot, for example:

MockFactory.create<User>(UserEntity, { count: 3 }).persist();

(can be also .snapshot(), needs to decide what's better)

The data has to be saved in a JSON file and needs to have a unique name - maybe the class/test file name. There is also another option - to pass a parameter to the persist() method with a unique slug:

MockFactory.create<User>(UserEntity, { count: 3 }).persist('simple-user-mock');
@omermorad omermorad added the suggestion Suggestion label Jul 11, 2021
omermorad added a commit that referenced this issue Jul 13, 2021
…ance

Add fluent API to enable methods chanining with ability to persist the mock

BREAKING CHANGE: MockFactory is now a function and not a class, changed the original to
MockGenerator. Add fluent API and ability to persist mock datta

closes #42, closes #37
@omermorad omermorad linked a pull request Jul 13, 2021 that will close this issue
omermorad added a commit that referenced this issue Jul 17, 2021
…51)

* refactor(mock-factory): change the return type of mock factory (#40)

* refactor(mock-factory): change the return type of mock factory

MockFactory will now return an instance of the class and not a plain object

BREAKING CHANGE: MockFactory is now an instance (TClass) and not ClassLiteral<TClass>

* chore: fix typo in the test name

* chore: change methods order

* chore: added source map and some jest configs

* refactor: change some var names and error

* test(class-processor): refactor test turning into integration instead of unit

* chore(lib): move files into lib folder and change imports

* feat(fluent-api): add fluent api (builder) functionality and persistence

Add fluent API to enable methods chaining with ability to persist the mock

BREAKING CHANGE: MockFactory is now a function and not a class, changed the original to
MockGenerator. Add fluent API and ability to persist mock data

closes #42, closes #37

* refactor: change mock names, remove test from tsconfig.json

* refactor: temp change to another class type

* fix: fix broken generic type in mock generator

* test: update integration snapshot and fix path issues

* chore: remove redundant example

* chore(mockingbird): refactor the structure of the project to be monorepo

* chore: fix settings of jest and monorepo

* ci: fix pipeline to work with yarn and lerna

* chore: remove redundant example file

* refactor: split into logical packages (#46)

* chore: monorepo settings and preparation

* refactor: split into logic packages, this is just the first suggested structure

* refactor: rearrange packages - fix broken tests and change names  (#47)

* chore: monorepo settings and preparation

* refactor: split into logic packages, this is just the first suggested structure

* refactor(mockingbird-ts): change processor to parser

* chore(mockingbird-ts): rearrange import style

* refactor(mockingbird-ts): import mock decorator from package

* refactor(mockingbird-ts): change processor to parser

* test(mockingbird-ts): fix and improve array value handler

* refactor(mockingbird-ts): change processor to parser

* chore(mockingbird-ts): rearrange import style

* refactor(mockingbird-ts): import mock decorator from package

* refactor(mockingbird-ts): change processor to parser

* test(mockingbird-ts): fix and improve array value handler

* chore(types): fix exit code

* fix: broken generator (#49)

* chore(types): fix lint typo

* test(mockingbird-ts): fix mock generator broken test

* refactor(parser): remove locale option

* refactor(mockingbird-ts): change names to parser and add locale option

* chore(types): fix lint typo

* test(parser): change file name and faker instance

* chore: add proper files, rearrange dependencies and package.json files (#50)

* chore(mockingbird-ts): update dependencies

* ci(repo): fix commit lint step

* ci(repo): fix commit lint step

* ci(repo): fix broken coverage step

* chore(mockingbird-ts): fix dependencies

* chore(repo): testing linting tactics (#52)

* chore(repo): change jest testing tactic to fully work with monorepo

* chore(mockingbird-ts): remove locale todo

* chore(repo): add root to eslint

* ci(repo): fix step lint in pipeline

* chore(repo): fix test:cov step

* chore(repo): fix test:cov step

* chore(repo): fix test:cov step

* chore(repo): add coverage to ignore

* chore(repo): modify lerna settings

* chore(version): publish

 - @mockinbird/parser@1.0.1-alpha.0
 - @mockinbird/reflect@1.0.1-alpha.0
 - @mockinbird/types@1.0.1-alpha.0

* chore(repo): modify lerna settings

* chore(mockingbird-ts): add test root to jest config

* refactor(mockingbird-ts): change back the name to factory and not generator

* chore(repo): re-version mockingbird-ts and rearrange changelog files

* ci(repo): add release branch to checks, fix release.yml and remove publishing
@omermorad omermorad self-assigned this Jul 25, 2021
@omermorad omermorad added enhancement 🎉 New feature or request and removed suggestion Suggestion labels Jul 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 🎉 New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant