asvetliakov / jest-create-mock-instance

Create mock instances with Jest
MIT License
34 stars 4 forks source link

createMockInstance function not found #1

Closed juanjo-ramos closed 6 years ago

juanjo-ramos commented 6 years ago

I'm trying to use this module in my environment, however I'm getting the following runtime error when running my tests:

TypeError: (0 , _jestCreateMockInstance2.default) is not a function

I'm not using TypeScript but flow and flow-type. No complaints from flow though.

This is how devDependencies object looks like in my package.json

"devDependencies": {
    "@storybook/addon-actions": "^3.2.8",
    "@storybook/react-native": "^3.2.8",
    "babel-cli": "^6.26.0",
    "babel-eslint": "^7.2.3",
    "babel-jest": "20.0.3",
    "babel-preset-react-native": "^2.0.0",
    "codecov": "github:keatongreve/codecov-node",
    "enzyme": "^3.1.1",
    "enzyme-adapter-react-16": "^1.0.4",
    "eslint": "^3.19.0",
    "eslint-config-airbnb": "^15.1.0",
    "eslint-config-hudl": "^5.0.0",
    "eslint-config-prettier": "^2.4.0",
    "eslint-config-zavatta": "^6.0.1",
    "eslint-import-resolver-reactnative": "^1.0.2",
    "eslint-plugin-import": "^2.3.0",
    "eslint-plugin-jsx-a11y": "^5.1.1",
    "eslint-plugin-prettier": "^2.2.0",
    "eslint-plugin-react": "^7.3.0",
    "eslint-plugin-react-native": "^3.1.0",
    "flow-bin": "^0.49.1",
    "flow-typed": "^2.2.3",
    "jest": "^20.0.4",
    "jest-create-mock-instance": "^1.0.2",
    "jest-teamcity-reporter": "^0.7.0",
    "prettier": "^1.9.2",
    "prettierrc": "^0.0.0-5",
    "react-test-renderer": "16.0.0-alpha.12",
    "redux-mock-store": "^1.3.0",
    "regenerator-runtime": "*",
    "rnpm-plugin-windows": "^0.2.5",
    "source-map": "^0.6.1"
  },

What can be causing the problem?

asvetliakov commented 6 years ago

Hello Juanjo, i see you're using jest 20.0, but jest-mock package which internally used by jest-create-mock-instance available only from jest 21.0. You can either upgrade your jest to v21 or v22 or install jest-mock package.

asvetliakov commented 6 years ago

Just checked and jest-mock available in jest 20. The error comes from export interop then. I'll check

Does the import { createMockInstance } from "jest-create-mock-instance" work ?