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

expect.createSpy is not a function #244

Closed
JairAviles opened this issue Feb 20, 2018 · 2 comments
Closed

expect.createSpy is not a function #244

JairAviles opened this issue Feb 20, 2018 · 2 comments

Comments

@JairAviles
Copy link

Env: cultofcoders:mocha + NodeJS 8.9.4 + npm@5.6.0 + expect@22.3.0

Working with a Meteor web app development I integrated the expect library (not using Jest) due to the fact that I am working with legacy code. Have defined in my React component file test as follows according to the README.md file

import expect, { createSpy } from 'expect';
...
        it('should call the function', function() {
            const spy = expect.createSpy();
            spy(3, 4, 123);
            expect(spy).toHaveBeenCalled();
        });

However, I am getting the following exception in the browser. What can I do to solve it?
P.d. Not able to migrate to Jest for now because as I said, I am refactoring a legacy code that should be updated in the future but not for the moment.

TypeError: expect.createSpy is not a function
    at Context.<anonymous> (app/app.js?hash=02726a842e2206be159a89a48d59fc6bbf963a7b:500:24)
    at callFn (packages/practicalmeteor_mocha-core.js?hash=8beea7367d1e32321cbe94d562492c67d7ddc5d2:4359:21)
    at Test.Runnable.run (packages/practicalmeteor_mocha-core.js?hash=8beea7367d1e32321cbe94d562492c67d7ddc5d2:4352:7)
    at Runner.runTest (packages/practicalmeteor_mocha-core.js?hash=8beea7367d1e32321cbe94d562492c67d7ddc5d2:4822:10)
    at packages/practicalmeteor_mocha-core.js?hash=8beea7367d1e32321cbe94d562492c67d7ddc5d2:4933:12
    at next (packages/practicalmeteor_mocha-core.js?hash=8beea7367d1e32321cbe94d562492c67d7ddc5d2:4742:14)
    at packages/practicalmeteor_mocha-core.js?hash=8beea7367d1e32321cbe94d562492c67d7ddc5d2:4752:7
    at next (packages/practicalmeteor_mocha-core.js?hash=8beea7367d1e32321cbe94d562492c67d7ddc5d2:4684:14)
    at packages/practicalmeteor_mocha-core.js?hash=8beea7367d1e32321cbe94d562492c67d7ddc5d2:4720:5
    at timeslice (packages/practicalmeteor_mocha-core.js?hash=8beea7367d1e32321cbe94d562492c67d7ddc5d2:12688:27)
@ljharb
Copy link
Sponsor Collaborator

ljharb commented Feb 20, 2018

expect v21+ is managed by jest; you’ll need to file the issue there.

@ljharb ljharb closed this as completed Feb 20, 2018
@JairAviles
Copy link
Author

Got it. At the end, I downgrade the expect library version to @1.20.2 and was able to continue with my spy definitions.

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

No branches or pull requests

2 participants