误差:"找不到模块' react-dom / test-utils'来自' ReactFifteenAdapter.js' "使用React 15.4.1进行jest-styled-components配置

时间:2017-11-01 06:16:45

标签: node.js reactjs enzyme jest styled-components

仅使用React版本15.4.1配置Jest-Styled-components时出错。

  

我们不会升级React版本。我们需要在上面进行配置   仅反应版本。

我确实安装了以下软件包 -

  1. 开玩笑风格成分
  2. 反应试验渲染器
  3. 酶到JSON
  4. 酶 - 接合体反应的-15
  5. 的package.json

       {
      "name": "app",
      "version": "0.0.1",
      "description": "",
      "engines": {
        "npm": ">=3",
        "node": ">=5"
      },
      "scripts": {
        "analyze:clean": "rimraf stats.json",
        "preanalyze": "npm run analyze:clean",
        "analyze": "node ./internals/scripts/analyze.js",
        "extract-intl": "babel-node --presets latest,stage-0 -- ./internals/scripts/extract-intl.js",
        "npmcheckversion": "node ./internals/scripts/npmcheckversion.js",
        "preinstall": "npm run npmcheckversion",
        "postinstall": "npm run build:dll",
        "prebuild": "npm run build:clean",
        "build": "cross-env NODE_ENV=production webpack --config internals/webpack/webpack.prod.babel.js --color -p --progress",
        "build:clean": "npm run test:clean && rimraf ./build",
        "build:dll": "node ./internals/scripts/dependencies.js",
        "start": "cross-env NODE_ENV=development node server",
        "server": "cross-env NODE_ENV=development nodemon server",
        "start:tunnel": "cross-env NODE_ENV=development ENABLE_TUNNEL=true node server",
        "start:production": "npm run test && npm run build && npm run start:prod",
        "start:prod": "cross-env NODE_ENV=production node server",
        "presetup": "npm i chalk shelljs",
        "setup": "node ./internals/scripts/setup.js",
        "postsetup": "npm run build:dll",
        "clean": "shjs ./internals/scripts/clean.js",
        "clean:all": "npm run analyze:clean && npm run test:clean && npm run build:clean",
        "generate": "plop --plopfile internals/generators/index.js",
        "lint": "npm run lint:js",
        "lint:eslint": "eslint --ignore-path .gitignore --ignore-pattern internals/scripts",
        "lint:js": "npm run lint:eslint -- . ",
        "lint:staged": "lint-staged",
        "pretest": "npm run test:clean && npm run lint",
        "test:clean": "rimraf ./coverage",
        "test": "cross-env NODE_ENV=test jest --coverage",
        "test:watch": "cross-env NODE_ENV=test jest --watchAll",
        "coveralls": "cat ./coverage/lcov.info | coveralls"
      },
      "babel": {
        "presets": [
          [
            "latest",
            {
              "es2015": {
                "modules": false
              }
            }
          ],
          "react",
          "stage-0"
        ],
        "env": {
          "production": {
            "only": [
              "app"
            ],
            "plugins": [
              "transform-react-remove-prop-types",
              "transform-react-constant-elements",
              "transform-react-inline-elements",
              "transform-object-rest-spread"
            ]
          },
          "test": {
            "plugins": [
              "transform-es2015-modules-commonjs",
              "dynamic-import-node"
            ]
          }
        }
      },
      "eslintConfig": {
        "parser": "babel-eslint",
        "extends": "airbnb",
        "env": {
          "browser": true,
          "node": true,
          "jest": true,
          "es6": true
        },
        "plugins": [
          "redux-saga",
          "react",
          "jsx-a11y"
        ],
        "parserOptions": {
          "ecmaVersion": 8,
          "sourceType": "module",
          "ecmaFeatures": {
            "jsx": true
          }
        },
        "rules": {
          "linebreak-style": 0,
          "arrow-parens": [
            "error",
            "always"
          ],
          "arrow-body-style": [
            2,
            "as-needed"
          ],
          "comma-dangle": [
            2,
            "always-multiline"
          ],
          "import/imports-first": 0,
          "import/newline-after-import": 0,
          "import/no-dynamic-require": 0,
          "import/no-extraneous-dependencies": 0,
          "import/no-named-as-default": 0,
          "import/no-unresolved": 2,
          "import/prefer-default-export": 0,
          "indent": [
            2,
            2,
            {
              "SwitchCase": 1
            }
          ],
          "jsx-a11y/aria-props": 2,
          "jsx-a11y/heading-has-content": 0,
          "jsx-a11y/href-no-hash": 2,
          "jsx-a11y/label-has-for": 2,
          "jsx-a11y/mouse-events-have-key-events": 2,
          "jsx-a11y/role-has-required-aria-props": 2,
          "jsx-a11y/role-supports-aria-props": 2,
          "max-len": 0,
          "newline-per-chained-call": 0,
          "no-confusing-arrow": 0,
          "no-console": 1,
          "no-param-reassign": 0,
          "no-use-before-define": 0,
          "no-unused-expressions": [
            "error",
            {
              "allowShortCircuit": true,
              "allowTernary": true
            }
          ],
          "prefer-template": 2,
          "class-methods-use-this": 0,
          "react/forbid-prop-types": 0,
          "react/jsx-first-prop-new-line": [
            2,
            "multiline"
          ],
          "react/jsx-filename-extension": 0,
          "react/jsx-no-target-blank": 0,
          "react/require-extension": 0,
          "react/self-closing-comp": 0,
          "redux-saga/no-yield-in-race": 2,
          "redux-saga/yield-effects": 2,
          "require-yield": 0,
          "import/no-webpack-loader-syntax": 0
        },
        "settings": {
          "import/resolver": {
            "webpack": {
              "config": "./internals/webpack/webpack.prod.babel.js"
            }
          }
        }
      },
      "dllPlugin": {
        "path": "node_modules/react-boilerplate-dlls",
        "exclude": [
          "chalk",
          "compression",
          "cross-env",
          "express",
          "ip",
          "minimist",
          "sanitize.css"
        ],
        "include": [
          "core-js",
          "lodash",
          "eventsource-polyfill"
        ]
      },
      "jest": {
        "collectCoverageFrom": [
          "app/**/*.{js,jsx}",
          "!app/**/*.test.{js,jsx}",
          "!app/*/RbGenerated*/*.{js,jsx}",
          "!app/app.js",
          "!app/routes.js"
        ],
        "coverageThreshold": {
          "global": {
            "statements": 98,
            "branches": 91,
            "functions": 98,
            "lines": 98
          }
        },
        "moduleDirectories": [
          "node_modules",
          "app"
        ],
        "moduleNameMapper": {
          ".*\\.(css|less|styl|scss|sass)$": "<rootDir>/internals/mocks/cssModule.js",
          ".*\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/internals/mocks/image.js"
        },
        "setupTestFrameworkScriptFile": "<rootDir>/internals/testing/test-bundler.js",
        "testRegex": "tests/.*\\.test\\.js$"
      },
      "dependencies": {
        "auth0-js": "8.6.1",
        "babel-polyfill": "6.23.0",
        "body-parser": "1.17.2",
        "chalk": "1.1.3",
        "compression": "1.6.2",
        "cross-env": "3.1.3",
        "dotenv": "^4.0.0",
        "express": "4.14.0",
        "fontfaceobserver": "2.0.7",
        "immutable": "3.8.1",
        "intl": "1.2.5",
        "invariant": "2.2.2",
        "ip": "1.1.4",
        "knex": "0.13.0",
        "lodash": "4.17.2",
        "mariasql": "0.2.6",
        "material-ui": "0.18.0",
        "minimist": "1.2.0",
        "moment": "2.18.1",
        "prop-types": "15.5.8",
        "react": "15.4.1",
        "react-dom": "15.4.1",
        "react-helmet": "3.2.2",
        "react-intl": "2.1.5",
        "react-redux": "4.4.6",
        "react-router": "3.0.0",
        "react-router-redux": "4.0.8",
        "react-router-scroll": "0.4.1",
        "react-tap-event-plugin": "2.0.1",
        "redux": "3.6.0",
        "redux-immutable": "3.0.8",
        "redux-saga": "0.14.0",
        "request": "^2.81.0",
        "reselect": "2.5.4",
        "sanitize.css": "5.0.0",
        "styled-components": "1.1.2",
        "svgo": "^0.7.2",
        "warning": "3.0.0",
        "whatwg-fetch": "2.0.1"
      },
      "devDependencies": {
        "babel-cli": "6.18.0",
        "babel-core": "6.25.0",
        "babel-eslint": "7.1.1",
        "babel-loader": "7.1.0",
        "babel-plugin-dynamic-import-node": "1.0.0",
        "babel-plugin-react-intl": "2.2.0",
        "babel-plugin-react-transform": "2.0.2",
        "babel-plugin-transform-es2015-modules-commonjs": "6.18.0",
        "babel-plugin-transform-object-rest-spread": "^6.23.0",
        "babel-plugin-transform-react-constant-elements": "6.9.1",
        "babel-plugin-transform-react-inline-elements": "6.8.0",
        "babel-plugin-transform-react-remove-prop-types": "0.2.11",
        "babel-preset-latest": "6.24.1",
        "babel-preset-react": "6.24.1",
        "babel-preset-react-hmre": "1.1.1",
        "babel-preset-stage-0": "6.24.1",
        "cheerio": "0.22.0",
        "circular-dependency-plugin": "2.0.0",
        "coveralls": "2.11.15",
        "css-loader": "0.26.1",
        "enzyme": "2.6.0",
        "enzyme-adapter-react-15": "^1.0.3",
        "enzyme-to-json": "^3.1.4",
        "eslint": "3.11.1",
        "eslint-config-airbnb": "13.0.0",
        "eslint-config-airbnb-base": "10.0.1",
        "eslint-import-resolver-webpack": "0.8.0",
        "eslint-plugin-import": "2.2.0",
        "eslint-plugin-jsx-a11y": "2.2.3",
        "eslint-plugin-react": "6.7.1",
        "eslint-plugin-redux-saga": "0.1.5",
        "eventsource-polyfill": "0.9.6",
        "exports-loader": "0.6.3",
        "file-loader": "0.9.0",
        "html-loader": "0.4.4",
        "html-webpack-plugin": "2.24.1",
        "image-webpack-loader": "2.0.0",
        "imports-loader": "0.6.5",
        "jest-cli": "18.0.0",
        "jest-styled-components": "^4.9.0",
        "lint-staged": "3.2.1",
        "ngrok": "2.2.4",
        "node-plop": "0.5.4",
        "null-loader": "0.1.1",
        "offline-plugin": "4.8.3",
        "plop": "1.7.3",
        "pre-commit": "1.1.3",
        "react-addons-test-utils": "15.4.1",
        "react-test-renderer": "^15.4.1",
        "redux-mock-store": "1.2.3",
        "rimraf": "2.5.4",
        "shelljs": "0.7.5",
        "sinon": "2.0.0-pre",
        "style-loader": "0.13.1",
        "url-loader": "0.5.7",
        "webpack": "2.2.0-rc.3",
        "webpack-dev-middleware": "1.9.0",
        "webpack-hot-middleware": "2.15.0"
      }
    }
    

    Style.test.js

    import 'babel-polyfill';
    import { configure } from 'enzyme'
    import Adapter from 'enzyme-adapter-react-15'
    configure({ adapter: new Adapter() })
    

    提前谢谢。

0 个答案:

没有答案