Skip to content

expect.any throws a type error #1520

Closed
Closed

Description

@chrisjcodes

If you are reporting a bug, please fill in below. Otherwise feel free to remove this template entirely.

Can you reproduce the problem with latest npm?

Reproducible with 18.1.0

Description

http://stackoverflow.com/questions/41942411/typeerror-expect-any-is-not-a-function

Expected behavior

expect.any(Constructor) should work as listed in the docs for Jest

Actual behavior

Throws a TypeError

Environment

NPM v3.10.3
Node v6.6.0

  1. Operating system: OSX
  2. Browser and version: Chrome, latest(56)

Activity

  1. gaearon commented on Feb 10, 2017

    @gaearon
    Contributor

    Could this be a new method in Jest 18? We are currently shipping Jest 17.
    An update with Jest 18 is coming within a few days.

  2. gaearon commented on Feb 11, 2017

    @gaearon
    Contributor

    Seems new in Jest 18. I can confirm it works on master and will work in react-scripts@0.9.0 we're cutting very soon.

  3. chrisjcodes commented on Feb 11, 2017

    @chrisjcodes
    Author

    Awesome thanks @gaearon

  4. gaearon commented on Feb 11, 2017

    @gaearon
    Contributor

    Should be available on 0.9.0 we just released.

  5. dangerismycat commented on Mar 1, 2017

    @dangerismycat

    I'm getting this error with 0.9.3, even after nuking and reinstalling node_modules. Any ideas on what I'm missing?

  6. gaearon commented on Mar 1, 2017

    @gaearon
    Contributor

    I can’t reproduce this. I added console.log(typeof expect.any) into src/App.test.js of a newly generated project, and it logs a function.

    So if you still have issues, you’ll need to create a project reproducing this.

  7. dangerismycat commented on Mar 1, 2017

    @dangerismycat

    Figured it out. Somehow I ended up with react-scripts as a dependency as well as a devDependency, and when I upgraded from a previous version, only the devDependency upgraded. So I was actually using an older version of Jest, pre-expect.any. D'oh!

  8. Timer commented on Mar 1, 2017

    @Timer
    Contributor

    @dangerismycat you probably ran something like npm upgrade react-scripts --save-exact; anyway, glad you figured it out!

  9. locked and limited conversation to collaborators on Jan 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions