0

I would like to run an integration test with msw + cypress + start-server-and-test

1- I have msw as a mock on the react app itself (port 3000) 2- I have a socket.io server in port 5000

my question is how to run it properly to make sure start-server-and-test will handle it I tried with concurrently. but I am not sure if this is the way

my package.json:

    "socket-server": "node test/socket/index.js"
    "start-server": "concurrently \"npm run socket-server\" \"cross-env NODE_ENV=development craco start\"",
    "test:e2e:ci": "start-server-and-test start-server \"3000\"  cypress:headless",

another issue is when I changed the port from 3000 to smth that unavailable the app stuck and the test does not close the app

thanks

Tuz
  • 1,810
  • 5
  • 29
  • 58

1 Answers1

0

OK fixed by use the "start-test" from the start-server-and-test library so in order to run both socket server + api or any list of server you can run this:

start-test <first command> <first resource> <second command> <second resource> <test command>

i.e

{
  "scripts": {
    "test": "node src/test",
    "start:api": "node src/api",
    "start:server": "node src/server",
    "test:all": "start-test start:api 3000 start:server 8080 test"
  }
}

this is also written in the docs

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

Tuz
  • 1,810
  • 5
  • 29
  • 58