簡體   English   中英

如何設置交叉環境變量以在提交前開始測試?

[英]How to set cross env variables to start tests before commit?

我已配置為在提交之前運行測試。 但它只適用於 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"
    }
  },

如何設置交叉環境變量以在任何操作系統中運行它們?

使用跨環境包:

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

你試過 .env.test 文件嗎? 有關 .env 中的信息,請參閱 React 文檔 create-react-app create-react-app 添加自定義變量

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM