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

Extract UnmockFaker from Backend. #355

Merged
merged 8 commits into from Dec 12, 2019
Merged

Extract UnmockFaker from Backend. #355

merged 8 commits into from Dec 12, 2019

Conversation

@ksaaskil
Copy link
Contributor

ksaaskil commented Dec 12, 2019

  • Extract UnmockFaker class responsible for faking responses to serialized requests, lifting that responsibility from Backend class.
  • Refactor unmock.nock so that the same API can be used also from UnmockFaker to add services
  • Add helper methods to ServiceStore: update, removeAll, resetServices

The purpose of all this is that one can separate the mock generation logic from the interceptor logic: one can create mock responses via UnmockFaker without starting the interceptor and add new services and modify their states. And it's nice that one can create multiple independent fakers, as the big bad global interceptor is separate from the faking logic.

ksaaskil added 4 commits Dec 12, 2019
@codecov-io

This comment has been minimized.

Copy link

codecov-io commented Dec 12, 2019

Codecov Report

Merging #355 into dev will decrease coverage by 0.64%.
The diff coverage is 77.64%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev     #355      +/-   ##
==========================================
- Coverage   81.06%   80.42%   -0.65%     
==========================================
  Files          53       54       +1     
  Lines        2361     2416      +55     
  Branches      577      586       +9     
==========================================
+ Hits         1914     1943      +29     
- Misses        447      473      +26
Impacted Files Coverage Δ
packages/unmock-core/src/nock.ts 74.73% <100%> (ø) ⬆️
packages/unmock-core/src/backend/index.ts 89.09% <100%> (-0.2%) ⬇️
packages/unmock-core/src/index.ts 79.24% <66.66%> (-5.76%) ⬇️
packages/unmock-core/src/service/serviceStore.ts 82.53% <73.17%> (-17.47%) ⬇️
packages/unmock-core/src/faker/index.ts 80.76% <80.76%> (ø)
...kages/unmock-node/src/loggers/filesystem-logger.ts 66.66% <0%> (-29.63%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0298b97...c7215de. Read the comment docs.

ksaaskil added 4 commits Dec 12, 2019
@ksaaskil ksaaskil requested a review from carolstran Dec 12, 2019
Copy link
Contributor

carolstran left a comment

Great work and really nice use of inline comments 💯

Do you think we should add information about UnmockFaker to any of the documentation (within the repo or on unmock.io)? If so, let me know and I can add it as an issue within the repo(s).

@carolstran carolstran merged commit c8ba193 into dev Dec 12, 2019
2 checks passed
2 checks passed
ci/circleci: build Your tests passed on CircleCI!
Details
ci/circleci: verify-before-publish Your tests passed on CircleCI!
Details
@carolstran carolstran deleted the extract-faker branch Dec 12, 2019
@ksaaskil

This comment has been minimized.

Copy link
Contributor Author

ksaaskil commented Dec 13, 2019

Yeah we should add something about it in the documentation! It's currently however more for internal development and it'll likely change quite a bit as new needs emerge, so I wouldn't maybe do that yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.