首页 > 解决方案 > 未找到命令:排毒

问题描述

我正在尝试将 detox e2e 测试添加到我的项目中。我浏览了它的文档,但是,我无法在我的机器上安装它。这是我的 devDependencies:

  "devDependencies": {
    "@babel/core": "^7.4.5",
    "@babel/plugin-proposal-class-properties": "^7.12.1",
    "@babel/preset-env": "^7.12.7",
    "@babel/preset-flow": "^7.12.1",
    "@babel/preset-react": "^7.12.7",
    "@babel/runtime": "^7.4.5",
    "@testing-library/jest-native": "^3.4.3",
    "@testing-library/react-native": "^7.1.0",
    "@types/react-native-sqlite-storage": "^3.3.1",
    "babel-eslint": "^10.0.3",
    "babel-jest": "^24.8.0",
    "babel-plugin-add-module-exports": "^1.0.4",
    "babel-plugin-dynamic-import-node": "^2.3.3",
    "babel-plugin-transform-remove-console": "^6.9.4",
    "detox": "^17.14.3",
    "jest": "^24.9.0",
    "jest-circus": "^26.6.3",
    "metro-react-native-babel-preset": "^0.54.1",
    "prettier": "^1.18.2",
    "react-test-renderer": "16.8.3"
  }

另外,我有installed npm install -g detox-cli,但我有command not found: detox

node : 10.22.1
os: Catalina
react-native: 0.61.2

标签: node.jsreact-nativenpmdetox

解决方案


我希望现在您已经找到了答案,但是对于其他有同样问题的开发人员,我的答案如下

1st 确保安装 detox CLI 不仅可以在您的项目中添加 detox,还可以使用:npm install -g detox-cli

第二,如果您使用 Expo CLI 而不是 react-native cli,这将是一个问题,因为对 Detox 的 Expo 支持完全是社区驱动的工作。我们在 Detox for Expo 应用程序中没有具体的支持。

如果您发现问题,很可能不是 Detox 本身的问题,而是 Expo 运行时或不正确的 Detox 设置问题。有关如何在 Expo 中使用 Detox 的支持,您应该联系 Expo 团队或 Expo 社区。

可以参考Expo github 团队,看到这个分辨率


推荐阅读