7

I am using create-react-app and I am running my development webpack server in https. So running npm run cypress:open, I would expect

  1. My application to run in https://localhost:3000
  2. Once the server is up, the cypress launcher to run on it.

Only the first step happens, cypress launcher is not opening up.

This is my scripts config in 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"
    }

I am facing this issue only for https, not http.

PCK
  • 1,254
  • 6
  • 20
  • 37
  • 1
    I have this same issue currently - did you find a solution? – Jared Nov 26 '19 at 18:42
  • I'm having the same problem, and I tried http-get; it just won't move to the cypress step. My "start" command is like this, which is just to set a couple of environment variables (HTTPS=false, GENERATE_SOURCEMAP=false, EXTEND_ESLINT=true): "env-cmd -f .env.development react-scripts start" – Marc Fearby Nov 02 '20 at 09:56
  • 1
    START_SERVER_AND_TEST_INSECURE=1 is working now for https. The command I used. "START_SERVER_AND_TEST_INSECURE=1 start-server-and-test https://localhost:3000 cypress-run" – Fiddler Aug 11 '21 at 21:16

2 Answers2

5

If you are running your application with HTTPS and your certificate is not valid, you can add START_SERVER_AND_TEST_INSECURE=1 as an environment variable.

"scripts": {
    "cypress:open": "START_SERVER_AND_TEST_INSECURE=1 start-server-and-test start https-get://localhost:3000 cy:open"
}

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

maxpaj
  • 6,029
  • 5
  • 35
  • 56
3

You're using http-get, but you probably need to use https-get since you're using HTTPS, not HTTP.

In your package.json, it should look like this:

{
  "scripts": {
    "cypress:open": "start-server-and-test start https-get://localhost:3000 cy:open"
  }
}

You can check out the wait-on usage docs for more info (start-server-and-test is based on wait-on)

Zach Bloomquist
  • 5,309
  • 29
  • 44
  • 3
    Although this is the a documented answer in `start-server-and-test` it does not currently work for `https`, even with the `START_SERVER_AND_TEST_INSECURE=1` flag. – Jared Nov 26 '19 at 18:43
  • 1
    Worked for me (create-react-app 4x) but I needed `START_SERVER_AND_TEST_INSECURE=1` as well as `https-get` – eddiewould Mar 10 '21 at 09:06