start-server-and-test - 不适用于 webpack-dev-server 的 https

CKA*_*CKA 8 https webpack-dev-server create-react-app cypress

我正在使用 create-react-app 并在 https 中运行我的开发 webpack 服务器。所以运行 npm run cypress:open,我期望

  1. 我的应用程序在https://localhost:3000中运行
  2. 服务器启动后,cypress 启动器将在其上运行。

仅发生了第一步,cypress 启动器未打开。

这是我在 package.json 中的脚本配置。

 "scripts": {
        "watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive",
        "start-js": "export HTTPS=true&&react-scripts start",
        "start": "npm-run-all -p watch-css start-js",
        "cy:open": "cypress open",
        "cypress:open": "start-server-and-test start http-get://localhost:3000 cy:open"
    }
Run Code Online (Sandbox Code Playgroud)

我只遇到 https 问题,而不是 http 问题。

max*_*paj 6

如果您使用 HTTPS 运行应用程序并且您的证书无效,您可以添加START_SERVER_AND_TEST_INSECURE=1为环境变量。

"scripts": {
    "cypress:open": "START_SERVER_AND_TEST_INSECURE=1 start-server-and-test start https-get://localhost:3000 cy:open"
}
Run Code Online (Sandbox Code Playgroud)

https://github.com/bahmutov/start-server-and-test#disable-https-certificate-checks


Zac*_*ist 3

您正在使用http-get,但您可能需要使用,https-get因为您使用的是 HTTPS,而不是 HTTP。

在你的 package.json 中,它应该如下所示:

{
  "scripts": {
    "cypress:open": "start-server-and-test start https-get://localhost:3000 cy:open"
  }
}
Run Code Online (Sandbox Code Playgroud)

您可以查看wait-on使用文档以获取更多信息(start-server-and-test基于wait-on

  • 尽管这是“start-server-and-test”中记录的答案,但它目前不适用于“https”,即使使用“START_SERVER_AND_TEST_INSECURE=1”标志也是如此。 (3认同)