thlorenz / proxyquire

🔮 Proxies nodejs require in order to allow overriding dependencies during testing.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support for wildcard strings

Floriferous opened this issue · comments

I have a use case where it would be helpful if I could stub modules using wildcard strings.

As an example, one of my own files isn't required during testing, and messes with my tests. But it is imported using various paths:

import bar from '../myModule'

or

import bar from '../../myModule'

I wish it was possible to stub it out this way:

proxyquire('./foo', { '*myModule': {} })

Is there another way I can do this now, or could this feature be added?

No way do to this. I doubt we'd ever include something like this, adding new module resolution outside of explicit/exact matching is against the spirit of proxyquire.

github.com/ariporad/pirates