0

我在运行测试套件时面临随机测试失败,但“无法读取未定义的属性”除外

我猜它与某处发生的竞争条件有关,但据我所知,无论代码故障点在哪里,我都在这些方法前面等待。我在某处读到它可能是版本问题 "react-test-renderer": "^16.5.2"

以下是我正在使用的依赖项:

 "devDependencies": {
    "apollo-boost": "^0.1.9",
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.3",
    "babel-eslint": "^8.2.3",
    "babel-jest": "^23.0.1",
    "babel-loader": "^7.1.4",
    "babel-plugin-lodash": "^3.3.4",
    "babel-plugin-react-css-modules": "^3.4.2",
    "babel-plugin-syntax-dynamic-import": "^6.18.0",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-flow": "^6.23.0",
    "babel-preset-react": "^6.24.1",
    "babel-register": "^6.26.0",
    "classnames": "^2.2.6",
    "commander": "^2.16.0",
    "cross-env": "^5.2.0",
    "css-loader": "^0.28.11",
    "enzyme": "^3.7.0",
    "enzyme-adapter-react-16": "^1.6.0",
    "enzyme-to-json": "^3.3.4",
    "eslint-plugin-graphql": "^3.0.3",
    "file-loader": "^1.1.11",
    "flow": "^0.2.3",
    "flow-bin": "^0.93.0",
    "flow-typed": "^2.5.1",
    "graphql-code-generator": "^0.17.0",
    "graphql-codegen-flow": "^0.17.0",
    "graphql-codegen-flow-resolvers": "^0.17.0",
    "graphql-tag": "^2.9.2",
    "graphql-tools": "^4.0.4",
    "grid-styled": "^4.1.1",
    "isomorphic-fetch": "^2.2.1",
    "jest": "^23.1.0",
    "leasot": "^6.3.0",
    "nock": "^9.4.3",
    "nodemon": "^1.18.6",
    "normalize.css": "^8.0.0",
    "npm-watch": "^0.6.0",
    "react": "^16.7.0",
    "react-apollo": "^2.3.2",
    "react-dates": "^17.2.0",
    "react-dom": "^16.3.1",
    "react-ga": "^2.5.7",
    "react-redux": "^5.0.7",
    "react-router-dom": "^4.3.1",
    "react-test-renderer": "^16.5.2",
    "react-toastify": "^4.2.0",
    "recharts": "^1.1.0",
    "redis-mock": "^0.43.0",
    "redux": "^4.0.0",
    "reselect": "^3.0.1",
    "rimraf": "^2.6.2",
    "sinon": "^6.0.0",
    "umzug": "^2.1.0",
    "webpack": "^4.12.0",
    "webpack-cli": "^3.0.3",
    "webpack-dev-middleware": "^3.1.3"
  }
 "dependencies": {
    "babel-plugin-transform-async-to-generator": "^6.24.1",
    "bluebird": "^3.5.0",
    "body-parser": "^1.16.0",
    "camelcase": "^5.0.0",
    "casual-browserify": "^1.5.19-2",
    "cheerio": "^1.0.0-rc.2",
    "connect-redis": "^3.4.0",
    "cookie-parser": "^1.4.3",
    "date-fns": "^1.29.0",
    "elasticsearch": "^15.1.1",
    "express": "^4.14.0",
    "express-graphql": "^0.6.12",
    "express-session": "^1.15.6",
    "express-socket.io-session": "^1.3.5",
    "file-loader": "^1.1.11",
    "graphql": "^0.13.2",
    "graphql-bigint": "^1.0.0",
    "graphql-relay": "^0.5.5",
    "graphql-sequelize": "^8.3.1",
    "graygelf": "^1.2.0",
    "immutable": "^4.0.0-rc.9",
    "lodash": "^4.17.10",
    "mkdirp": "^0.5.1",
    "moment": "^2.22.2",
    "mysql2": "^1.5.3",
    "n": "^2.1.12",
    "nc": "^1.0.2",
    "node-resque": "^5.5.1",
    "node-schedule": "^1.3.2",
    "pm2": "^2.2.3",
    "redis": "^2.8.0",
    "request": "^2.87.0",
    "request-promise": "^4.2.2",
    "winston": "^3.0.0"
  }

我期望测试与失败/成功一致。有人可以帮助了解出了什么问题吗?

4

1 回答 1

0

看起来代码中存在一些竞争条件并且添加等待(这可能是解决任何问题的最糟糕的方法!)有所帮助。

于 2019-05-10T19:30:18.040 回答