ike18t / ts-mockery

Simple type-safe typescript mocking library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

I need to be able to have a mock that does not get spied on.

ike18t opened this issue · comments

We noticed issues when we gave instantiated base class objects to Mock.of. The reason being that the type checker does not look at the prototype.

import { Mock } from 'ts-mockery';
Mock.of<SomeClass>(new BaseOfSomeClass());

now with Mock.from:

import { Mock } from 'ts-mockery';
Mock.from<SomeClass>(new BaseOfSomeClass());

Also when setting mocked property to an observable there is a circular reference that would throw an RangeError {}

import { Mock } from 'ts-mockery';
import { of } from 'rxjs';
Mock.of<SomeClass>({ something$: of(someValue) });

now with Mock.from:

import { Mock } from 'ts-mockery';
import { of } from 'rxjs';
Mock.from<SomeClass>({ something$: of(someValue) });

Solved by: 8bae092