message: Improve error messaging from "spyOn"
diff: @@ -644,7 +644,7 @@ class ModuleMockerClass {
  }
  isMockFunction(fn: any): boolean {
  - return !!fn._isMockFunction;
  + return !!(fn && fn._isMockFunction);
  }
  fn(implementation?: any): any {
  @@ -657,12 +657,22 @@ class ModuleMockerClass {
  }
  spyOn(object: any, methodName: any): any {
  + if (typeof object !== 'object' && typeof object !== 'function') {
  + throw new Error(
  + 'Cannot spyOn on a primitive value; ' + this._typeOf(object) + ' given',
  + );
  + }
  +
  const original = object[methodName];
  if (!this.isMockFunction(original)) {
  if (typeof original !== 'function') {
  throw new Error(
  - 'Cannot spyOn the ' + methodName + ' property; it is not a function',
  + 'Cannot spy the ' +
  + methodName +
  + ' property because it is not a function; ' +
  + this._typeOf(original) +
  + ' given instead',
  );
  }
  @@ -691,6 +701,10 @@ class ModuleMockerClass {
  this._spyState.forEach(restore => restore());
  this._spyState = new Set();
  }
  +
  + _typeOf(value: any): string {
  + return value == null ? '' + value : typeof value;
  + }
  }
  export type ModuleMocker = ModuleMockerClass;
  