question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add value to MockComponent

See original GitHub issue

Expected behaviour: Values written into MockComponent using writeValue should be stored inside custom components for verification of binding in unit tests.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
satanTimecommented, Jun 29, 2019

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 set value property when writeValue has been called you should use callFake to achieve your goals.

0reactions
privettolicommented, Jun 29, 2019

Really, that makes perfect sense. 😃 Consider the issue to be closed then.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found