Skip to content

Dynamic mocking with Proxies #20

Closed
@roblourens

Description

I came here with the same question as in #16, and it sounds like you need an instance of the mocked object so you can grab its properties and add them to your mock proxy. I was wondering if you ever thought about solving this with the new ES6 Proxy, which would let you intercept calls in 'setup'. It's basically designed for this scenario. We would be able to write

.setup(m => m.myFunction())

and it would call the 'get' handler on your Proxy object with 'myFunction' as an argument, for example. Does that make sense?

I would find this especially useful because I'm trying to mock an API which is defined with a .d.ts file + a Proxy object, so there is nothing to query the properties from.

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions