Javascript 如何设置跨环境变量以在提交之前启动测试?

Javascript 如何设置跨环境变量以在提交之前启动测试?,javascript,reactjs,testing,environment-variables,Javascript,Reactjs,Testing,Environment Variables,我已配置为在提交之前运行测试。但它只适用于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" }, "h

我已配置为在提交之前运行测试。但它只适用于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"
    }
  },
如何设置跨环境变量以在任何操作系统中运行它们?

使用该软件包:


您是否尝试过使用.env.test文件?请参阅React docs以获取创建React应用程序中.env的信息

您可以尝试
“预提交”:“跨环境节点\u env=test&&npm运行测试:all”
  "test:all": "cross-env CI=true react-scripts test"