bahmutov / start-server-and-test

Starts server, waits for URL, then runs test command; when the tests end, shuts down server
MIT License
1.54k stars 96 forks source link

webpack dev server proxy doesn't work well with start-server-and-start #163

Open rodoabad opened 5 years ago

rodoabad commented 5 years ago

Thank you for taking time to open a new issue. Please answer a few questions to help us fix it faster. You can delete text that is irrelevant to the issue.

Is this a bug report or a feature request?

If this is a bug report, please provide as much info as possible

Assume you are running two servers - web and api

Web:8080 Api: 8000

Web proxies * at 8000.

config.devServer.proxy = {
    '**': {
        bypass(request) {
            if (request.headers.accept.indexOf('html') !== -1) {
                return '/index.html';
            }

            return false;
        },
        target: 'http://localhost:8000'
    }
};
    "cypress:run": "cypress run",
    "start:server": "npx foo --type server",
    "start:api": "npx foo -- type api",
    "start:server-with-api": "start-test start:api 8000?url=api start:server",
    "test:acceptance": "start-test server-with-api http-get://localhost:5555 cypress:run",

When checking for server, request header is undefined and cypress:run cannot start.

rodoabad commented 5 years ago

Anyone here able to test this out?

iamgollum commented 5 years ago

Working on a similar issue now with CRA starter and proxy. I am getting a different error:

Proxy error: Could not proxy request / from localhost:3000 to http://localhost:3001.
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (ECONNREFUSED).

In package,json

"proxy": "http://localhost:3001",
....
  "test:acceptance": "start-server-and-test start:cli http://localhost:3000 cy:run",

Maybe its related but trying to figure it out.

rajzik commented 5 years ago

@iamgollum When using webpack dev server use http-get:// instead of http://.

https://www.npmjs.com/package/start-server-and-test#note-for-webpack-dev-server-users

Can you replicate this issue somehow?