Skip to content

Cannot find module 'setupDevtools' from 'setup.js' in react-native/jest/setup.js version 0.56.0 #20460

Closed
@davidpricedev

Description

Environment

node version 8.11.3 (and other windows systems have older yarn and node versions)

  React Native Environment Info:
    System:
      OS: Windows 10
      CPU: x64 Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
      Memory: 11.10 GB / 15.96 GB
    Binaries:
      Yarn: 1.9.2 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 5.6.0 - C:\Program Files\nodejs\npm.CMD
    IDEs:
      Android Studio: Version  3.1.0.0 AI-173.4720617

Description

Since upgrading to react-native 0.56.0, I can no longer run tests on windows. Every test file fails with the error below

FAIL startup/App.spec.js
● Test suite failed to run
Cannot find module 'setupDevtools' from 'setup.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:221:17)
at Object. (node_modules/react-native/jest/setup.js:33:6)

Jest Config I think everything below the `setupFiles` was stuff I added that made no effective difference.
{
    preset: 'react-native',
    collectCoverageFrom: [
        '**/*.{js}',
        '!**/node_modules/**',
        '!**/vendor/**',
        '!**/native-base-theme/**'
    ],
    testPathIgnorePatterns: [
        '/node_modules/'
    ],
    transform: {
        '^.+\\.js$': '<rootDir>/node_modules/react-native/jest/preprocessor.js'
    },
    transformIgnorePatterns: [
        '/node_modules/(?!native-base)/'
    ],
    setupFiles: [
        './testSetup.js'
    ],
    testRegex: "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx|js)$",
    moduleDirectories: [
        'node_modules'
    ]
}
Package.json
{
  "devDependencies": {
    "@babel/core": "7.0.0-beta.47",
    "@babel/plugin-proposal-decorators": "7.0.0-beta.47",
    "@babel/plugin-transform-runtime": "7.0.0-beta.47",
    "@babel/runtime": "7.0.0-beta.47",
    "babel-eslint": "^8.0.1",
    "babel-jest": "^23.4.0",
    "babel-plugin-extensible-destructuring": "4.2.1",
    "babel-plugin-jest-hoist": "^23.2.0",
    "babel-plugin-transform-remove-console": "^6.8.5",
    "babel-preset-react-native": "^5.0.0",
    "enzyme": "^3.3.0",
    "enzyme-adapter-react-16": "^1.1.1",
    "eslint": "^4.10.0",
    "eslint-loader": "^1.9.0",
    "eslint-plugin-babel": "^4.1.2",
    "eslint-plugin-import": "^2.7.0",
    "eslint-plugin-jest": "^21.3.2",
    "eslint-plugin-prettier": "^2.3.1",
    "eslint-plugin-react": "^7.1.0",
    "flow": "^0.2.3",
    "flow-bin": "^0.75.0",
    "jest": "23.4.1",
    "madge": "^3.0.1",
    "patch-package": "^5.1.1",
    "postinstall-prepare": "^1.0.1",
    "prettier-eslint-cli": "^4.6.1",
    "react-dom": "^16.1.1",
    "react-test-renderer": "16.4.1",
    "semver-regex": "^1.0.0",
    "shelljs": "^0.7.8"
  },
  "dependencies": {
    "axios": "^0.17.1",
    "base-64": "^0.1.0",
    "base64-js": "^1.3.0",
    "bcryptjs": "^2.4.3",
    "buffer": "^5.0.8",
    "core-js": "2.5.2",
    "events": "^1.1.1",
    "extensible-runtime": "^4.1.0",
    "he": "^1.1.1",
    "lodash": "^4.17.4",
    "moment": "^2.19.1",
    "moment-timezone": "^0.5.17",
    "prettier": "^1.9.1",
    "prop-types": "^15.6.0",
    "react": "16.4.1",
    "react-native": "0.56.0",
    "react-navigation": "^1.0.0-beta.19",
    "redux": "^3.7.2",
    "redux-saga": "^0.16.0",
    "urijs": "^1.19.0",
    "util": "^0.10.3"
  },
  "resolutions": {
    "core-js": "2.5.2"
  }
}

What I've already tried

  • I tried a bunch of things from a few semi-related issues: Jest #3822, stryker-mutator #717, StackOverflow A, B, C
  • Tried upgrading to the latest yarn, and node.
  • Tried many changes to my jest config based on the suggestions above
  • Tried throwing away my yarn.lock file so it would grab the latest version of everything subject to package.json
  • The repo below and snippets above are vastly stripped down from the original versions that I started with
  • Tried installing babel-core@7.0.0-bridge.0 as a dev dependency since yarn complains about it being a missing peer dependency

Things that affect the error:

If I remove the transform section of the jest config then the setup.js error goes away, but the "Plugin 0" error occurs (on macOs too):

Plugin 0 specified in "/Users/me/dev/myApp/node_modules/babel-preset-react-native/index.js" provided an invalid property of "default" (While processing preset: "...")

If I add the following to my jest config, the error changes to the error below

    rootDir: '.',
    roots: [
        '<rootDir>'
    ],

FAIL startup/App.spec.js
● Test suite failed to run
Reference Error babelHelpers is not defined

1 | import App from './App';
| ^
2 |
3 | describe('App', () => {
4 | it('Will render', () => {
at Object. (startup/App.spec.js:1:52)

Reproducible Demo

See: this repo for a reproducible (on windows only) example.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions