mfncooper / mockery

Simplifying the use of mocks with Node.js
Other
1.1k stars 60 forks source link

registerMock allow regexp as mod parameter #36

Open istarkov opened 8 years ago

istarkov commented 8 years ago

We use mockery also to mock requires on css, svg and all other files which we include using webpack loaders. It's more faster than precompile tests with webpack (and also there are a lot of issues using webpack with jsdom together). So we write something like this

mockery.registerMock('./MayBeInput.scss', {});
mockery.registerMock('./button.scss', {});
...etc

but we want this

mockery.registerMock(/\.scss$/, {});

if I create pull request allowing using regexp, do you accept it?

nampas commented 8 years ago

This would be a great addition, I'm running into the same problem. I have to individually mock out css files in all tests. Was there a particular reason why only exact matches are supported now?