jameslnewell / xhr-mock

Utility for mocking XMLHttpRequest.
196 stars 48 forks source link

RegEx not matching #20

Closed AnnaKalkanis closed 7 years ago

AnnaKalkanis commented 7 years ago

When using RegEx, my request is not matching mock.

 mock.mock('PUT', /.*\/uploads\/.*/,
      (req, res) => res.status(200).body("")
);

and

mock.put(/.*\/uploads\/.*/,
      (req, res) => res.status(200).body("")
);

It works fine when I use the actual url, but does not seem to match against various valid RegExs that I've tried. Am I formatting this incorrectly? Is it possible to use a wildcard?

AnnaKalkanis commented 7 years ago

Ahhh, my mistake. Didn't realize the regex matching hasn't been published to npm. Any plan to release a new version?

jameslnewell commented 7 years ago

Sorry about that! I think I was waiting on https://github.com/jameslnewell/xhr-mock/pull/16 to be complete which adds similar functionality and some bug fixes. I've published 1.8.0 in the mean time.

Let me know if you have any more issues!