How to use jest.spyOn() on a read only property?

Viewed 405

I have a library and need to test a method:

foo.foo1.foo2.method()

In my test, I have:

import * as foo from 'foo';

spyOn(foo.foo1.foo2, 'method')

I get this error after running my test:

TypeError: Cannot assign to read only property 'method' of object '[object Object]'

Any idea how can I fix this?

0 Answers
Related