Skip to content

Commit

Permalink
Merge pull request #96 from dirkluijk/fix/jest-typing-fix
Browse files Browse the repository at this point in the history
fix(jest): fix for incorrect typing of SpyObject for Jest
  • Loading branch information
NetanelBasal committed Mar 30, 2019
2 parents 49d61e9 + 1cc0a36 commit 134ab71
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion projects/spectator/jest/src/mock.ts
@@ -1,7 +1,7 @@
import { Provider, Type } from '@angular/core';
import { CompatibleSpy, SpyObject as BaseSpyObject, installProtoMethods } from '@netbasal/spectator';

export type SpyObject<T> = BaseSpyObject<T> & { [P in keyof T]: T[P] & jest.Mock<T> };
export type SpyObject<T> = BaseSpyObject<T> & { [P in keyof T]: T[P] & (T[P] extends (...args: any[]) => infer R ? jest.Mock<R> : T[P]) };

export function createSpyObject<T>(type: Type<T>, template?: Partial<Record<keyof T, any>>): SpyObject<T> {
const mock: any = template || {};
Expand Down
3 changes: 3 additions & 0 deletions projects/spectator/package.json
Expand Up @@ -27,5 +27,8 @@
"jquery": "3.3.1",
"schematics-utilities": "^1.1.1"
},
"peerDependencies": {
"typescript": ">= 2.8.0"
},
"schematics": "./schematics/collection.json"
}

0 comments on commit 134ab71

Please sign in to comment.