title: jasmine.createSpyObj with properties
body: <p>When mocking dependencies in my Angular tests, I usually create a spy object using <code>jasmine.createSpyObj</code>:</p>
  <pre><code>const serviceSpy= jasmine.createSpyObj('MyService', ['method']);
  </code></pre>
  <p>then provide it to the TestBed:</p>
  <pre><code>  providers: [
      {provide: MyService, useValue: serviceSpy}
    ]
  </code></pre>
  <p>When I use it in my test, I can then specify the desired return value:</p>
  <pre><code>serviceSpy.method.and.returnValue(of([...]));
  </code></pre>
  <p>Now I also need to mock properties and I cannot find out how it should be done. <code>createSpyObj</code> does allow the definition of property names:</p>
  <pre><code>const serviceSpy= jasmine.createSpyObj('MyService', ['method'], ['property']);
  </code></pre>
  <p>but I've tried varies solutions based on the numerous articles and answers out there without any success, e.g.:</p>
  <pre><code>// Cannot read property 'and' of undefined    
  serviceSpy.property.and.returnValue(true);  
  // not declared configurable
  spyOnProperty(serviceSpy, 'property').and.returnValue(true);  
  // no build errors, but value stays 'undefined'
  serviceSpy.property = true;  
  </code></pre>
  <p>The only way I could make it 'half' work is:</p>
  <pre><code>let fakeValue = true;
  const serviceSpy= jasmine.createSpyObj('MyService', ['method'], {'property': fakeValue});
  </code></pre>
  <p>The problem here is that it's a one-time set at creation. If I want to change the expected value in the test, it does not work.</p>
  <pre><code>fakeValue = false;
  serviceSpy.property ==&gt; stays to the initial value 'true';
  </code></pre>
  <p>Does there exist a solution to both mock methods and properties by creating a spy object, or should I create my own fake class on which I can then use <code>spyOn</code> and <code>spyOnProperty</code>?</p>
  <p>I would also like to know what the usage is of the properties array in the <code>createSpyObj</code> definition. So far I have not seen any example on the web that explains it.</p>