Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fakes - no way to override promise library in fakes #2293

Closed
fearphage opened this issue Aug 29, 2020 · 1 comment
Closed

Fakes - no way to override promise library in fakes #2293

fearphage opened this issue Aug 29, 2020 · 1 comment

Comments

@fearphage
Copy link
Member

Fakes are hard coded to use the global Promise library:

sinon/lib/sinon/fake.js

Lines 64 to 78 in 9d4a01b

fake.resolves = function resolves(value) {
function f() {
return Promise.resolve(value);
}
return wrapFunc(f);
};
fake.rejects = function rejects(value) {
function f() {
return Promise.reject(getError(value));
}
return wrapFunc(f);
};

There is no way to override this behavior and use an alternative library (like bluebird).

Similar interfaces that support this functionality:

  • sandbox.usingPromise()
  • stub.usingPromise()
fatso83 pushed a commit that referenced this issue Oct 13, 2020
* Add usingPromise() method on fakes to fix issue #2293

* Simplify implementation of injected promise implementation, reducing required code branching

Co-authored-by: Roman Balayan <roman.balayan@paymaya.com>
@mroderick
Copy link
Member

This has been fixed with #2301

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants