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

Not compatible with [email protected] createSandbox (chain is not a function) #44

Open
mauron85 opened this issue Mar 3, 2019 · 4 comments
Assignees
Labels
PRs Welcome PRs Welcome

Comments

@mauron85
Copy link

mauron85 commented Mar 3, 2019

Hi there,

I'm happy user of sinon-mongoose 2.2.1 and find it very usefull. It worked just fine until sinon 7.2.3, which was not compatible with created sandbox (sinon.createSandbox) but was compatible with default sandbox.

Starting version 7.2.6 sinon-mongoose is not compatible nor with default nor with created sanbox (sandbox.createSandbox).

I know there is #15 and also PR #19.

EDIT: added test for non default sandbox.

describe('using sinon createSandbox', function() {
    var sanbox = sinon.createSandbox();

    beforeEach(function() {
        sanbox.restore();
    });

    afterEach(function() {
        sanbox.verify();
    });

    it('should work mocking Model', function() {
        var BookMock = sanbox.mock(Book);

        BookMock.expects('find')
            .withArgs('SOME_ARGUMENTS')
            .chain('exec')
            .resolves('RESULT');

        Book.find('SOME_ARGUMENTS')
            .exec()
            .then(function(result) {
                assert.equal(result, 'RESULT');
            });
    });
});

It fails with error:

  2) sinon-mongoose
       using sinon sandbox
         should work mocking Model:
     TypeError: BookMock.expects(...).withArgs(...).chain is not a function
      at Context.<anonymous> (test/index.js:159:10)
@mauron85 mauron85 changed the title Not sinon.createSandbox compatible (chain is not a function) Not compatible with [email protected] default or createSandbox (chain is not a function) Mar 3, 2019
@YasharF
Copy link
Contributor

YasharF commented Apr 8, 2019

The related PRs have been merged/closed. Are you still having an issue?

@mauron85
Copy link
Author

mauron85 commented Apr 8, 2019

Yes, it's still relevant. You can try against provided test, which is basically same as in your suite, but using sinon.createSandbox() instead of default one.

EDIT: I've updated issue. Removed claim about not working with default sandbox, because I must first check, if it's just sinon version incompatibility or if mongoose is involved too. However claim about not working with sinon.createSandbox() is valid.

@mauron85 mauron85 changed the title Not compatible with [email protected] default or createSandbox (chain is not a function) Not compatible with [email protected] createSandbox (chain is not a function) Apr 8, 2019
@PierreCookie
Copy link

PierreCookie commented Jun 5, 2019

Do you have any substitue of this method, until the issue will be solve ?

Not working with sinon 7.3.2 & sinon-mongoose 2.3.0

@seyaobey
Copy link

seyaobey commented Jun 9, 2019

I am facing the same error with sinon-mongoose 7.3.2. I am a first-time of sinon-mongoose. What are the earlier versions of sinon-mongoose and sinon where they both work together? I would like to revert to them until maybe there is a solution.

Thank you for this library.

@YasharF YasharF added the PRs Welcome PRs Welcome label Jun 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PRs Welcome PRs Welcome
Projects
None yet
Development

No branches or pull requests

5 participants