0

I am using create-react-app for my building my application and I am using cypress for automation.

    "scripts": {
    "build-css": "node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/",
    "watch-css": "npm run build-css && node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive",
    "start-js": "react-scripts start",
    "start": "npm-run-all -p watch-css start-js",
    "cy:run": "cypress run ,
    "cypress:all": "start-server-and-test start http-get://localhost:3000 cy:run"
}

In order to run the test, firstly I need to boot up my application using npm start and then I can run command npm run cy:run -- --record --key <record-key>.

Instead what I am doing is run the command npm run cypress:all which will call npm start and once server is up and running it runs tests on it. But how do I pass the record flag for this command? npm run cypress:all -- --record <record-key> doesn't work here.

PCK
  • 1,254
  • 6
  • 20
  • 37

1 Answers1

0

The start-server-and-test docs says

In addition to using NPM script names, you can pass entire commands (surround them with quotes so it is still a single string) that will be executed "as is". For example, to start globally installed http-server before running and recording Cypress.io tests you can use start-server-and-test 'http-server -c-1 --silent' 8000 './node_modules/.bin/cypress run --record'

NoriSte
  • 3,589
  • 1
  • 19
  • 18
  • './node_modules/.bin/cypress run. I find it untidy. That's why I'd like to have a npm script – PCK Apr 30 '19 at 07:11