Skip to content

Commit

Permalink
fix spyComponents
Browse files Browse the repository at this point in the history
  • Loading branch information
menduz committed Oct 8, 2022
1 parent 40ebfa8 commit fa94157
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export function createRunner<TestComponents extends Record<string, any>>(
function spy<T extends {}>(module: T): SpiedInstance<T> {
const ret = {} as SpiedInstance<T>
for (let key in module) {
ret[key as keyof T] = jest.spyOn(module, key as any) as any
if (typeof module[key] === "function") {
ret[key as keyof T] = jest.spyOn(module, key as any) as any
}
}
return ret
}
Expand Down
2 changes: 2 additions & 0 deletions test/simple-smoke-test/jest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ type Components = {
componentB: {
sum(a: number, b: number): number
counter(): number
t: number
}
}

Expand All @@ -31,6 +32,7 @@ const test = createRunner<Components>({
counter() {
return counter
},
t: 3
}

return { componentA, componentB }
Expand Down

0 comments on commit fa94157

Please sign in to comment.