start-server-and-test - 无法与webpack-dev-server的https一起工作

8

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

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

只有第一步发生了,cypress启动器没有打开。

这是我的package.json文件中的scripts配置:

 "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"
    }

我只在https时遇到了这个问题,而不是http。

1
我目前也遇到了同样的问题 - 你找到解决方案了吗? - Jared
我遇到了同样的问题,我尝试使用http-get,但它就是无法进入cypress步骤。我的“start”命令如下,只是设置了一些环境变量(HTTPS=false,GENERATE_SOURCEMAP=false,EXTEND_ESLINT=true):“env-cmd -f .env.development react-scripts start”。 - Marc Fearby
1
START_SERVER_AND_TEST_INSECURE=1 现在可用于 https。我使用的命令是 "START_SERVER_AND_TEST_INSECURE=1 start-server-and-test https://localhost:3000 cypress-run"。 - Fiddler
2个回答

6

3
你正在使用 http-get,但由于你使用的是 HTTPS 而不是 HTTP,所以你可能需要使用 https-get
在你的 package.json 文件中应该像这样:
{
  "scripts": {
    "cypress:open": "start-server-and-test start https-get://localhost:3000 cy:open"
  }
}

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

3
虽然这是 start-server-and-test 的一个已记录答案,但目前它对于 https 并不起作用,即使使用了 START_SERVER_AND_TEST_INSECURE=1 标志。 - Jared
1
对我有用(create-react-app 4x),但我还需要 START_SERVER_AND_TEST_INSECURE=1https-get - eddiewould

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接