start-server-and-test icon indicating copy to clipboard operation
start-server-and-test copied to clipboard

How to start API-server in different directory?

Open xaviarnl opened this issue 6 years ago • 1 comments

I am running v1.7.12 of start-server-and-test, and I am trying to start both my Vue application as well as my API-server, so I can run my Cypress tests.

However, the API server is in a different (higher) directory than the Vue application, so "npm run start" will not work. However, I found out that I can start the API server from my Vue app directory, by using the following command: npm run start --prefix ../

So, with that in mind, I added the following lines to the "scripts" section of package.json: "test": "cypress run", "start:api": "npm run serve", "start:server": "npm run start --prefix ../", "start:server-and-api": "start-test start:api 3000 start:server", "test:all": "start-test start:api 3000 start:server 5000"

And then I started the test with: npm run test:all However, when I try to use this command with start-server-and-test, I run into an exception. You can look at the full debug log of this error: 2019-04-03T08_28_10_343Z-debug.log

Is this a bug in start-server-and-test? Or is it perhaps a feature which is not supported (yet) by this package?

small correction: I see that I have switched the settings for the API and the Vue server around, so here is what my configuration looks like when I correct that: "start:server": "npm run serve", "start:api": "npm run start --prefix ../", "start:server-and-api": "start-test start:api 3000 start:server", "test:all": "start-test start:api 3000 start:server 5000" The exception/error remains, however.

xaviarnl avatar Apr 03 '19 08:04 xaviarnl

it is hard to say what is going one (try running with DEBUG flag), but maybe just use commands instead of NPM script names - this is possible since v1.8.0

https://github.com/bahmutov/start-server-and-test#npx-and-yarn

bahmutov avatar Apr 24 '19 18:04 bahmutov