Add value to MockComponent
See original GitHub issueExpected behaviour:
Values written into MockComponent using writeValue
should be stored inside custom components for verification of binding in unit tests.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
How to mock components in Angular tests
A mock component in Angular tests can be created by MockComponent function. The mock component ... it('sends the correct value to the child...
Read more >How to mock an @INPUT value in tests for angular component
In my angular app, I am writing a testcase for a component which has @Input value. How can I mock the @Input value....
Read more >24. Mocking the Child Component and add that Fake ...
In this video we will see how to mock the child component in the test file and add it in the Test Bed...
Read more >mock-component - npm
Function creating a mock based on a passed in component for test. Latest version: 5.1.0, last published: 5 years ago.
Read more >zdennis/ng2-mock-component: An Angular 2 module ... - GitHub
A very simple Angular 2 module for mocking components in unit tests. npm install --save-dev ng2-mock-component ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
then there’s no reason to change code in the library, you can assert value by
expect(component.writeValue).toHaveBeenCalledWith(expectedValue)
. The idea of mocks is to isolate the behavior of the object you want to replace the other objects by mocks that simulate the behavior of the real objects. And how to simulate the behavior should be defined by developer, not by library. So if you want to setvalue
property whenwriteValue
has been called you should usecallFake
to achieve your goals.Really, that makes perfect sense. 😃 Consider the issue to be closed then.