【问题标题】:How to set cross env variables to start tests before commit?如何设置交叉环境变量以在提交前开始测试?
【发布时间】:2019-11-28 04:45:47
【问题描述】:

我已配置为在提交前运行测试。但它只适用于 Ubuntu。

这是我现在拥有的:

 "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject",
    "test:all": "CI=true react-scripts test"
  },
  "husky": {
    "hooks": {
      "pre-commit": "npm run test:all"
    }
  },

如何设置跨环境变量以在任何操作系统中运行它们?

【问题讨论】:

标签: javascript reactjs testing environment-variables


【解决方案1】:

使用cross-env 包:

  "test:all": "cross-env CI=true react-scripts test"

【讨论】:

    【解决方案2】:

    您是否尝试过使用 .env.test 文件?有关 create-react-app create-react-app adding custom variables中 .env 的信息,请参阅 React 文档

    【讨论】:

      猜你喜欢
      • 2019-11-26
      • 2021-08-10
      • 1970-01-01
      • 1970-01-01
      • 2021-10-08
      • 1970-01-01
      • 2023-03-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多