mjackson / expect

Write better assertions
MIT License
2.29k stars 117 forks source link

Access original spied object? #104

Closed ericclemmons closed 8 years ago

ericclemmons commented 8 years ago

Here's something that I'd like to do:

var spy = expect.spyOn(require, "resolve").andCall(function(path) {
  if (path.match(/something/) {
    return spy.original("fixture_instead.js");
  }

  return spy.andCallThrough();
});

Clearly I just violated half of the API, but didn't know if this was something you'd consider.

mjackson commented 8 years ago

You could just save off a reference to require.resolve before you spy on it. I'd rather not include API for this, but if others find it useful as well we would definitely consider it.