1

My package.json looks like this:

"scripts": {
  "test": "firebase emulators:exec --only firestore --project sample 'jest --runInBand'",
}

Is it possible to run npm test -- --watch?

If I do as it is now, I got:

npm test -- --watch

> functions@ test /home/ubuntu/workspace/blinktrade/otc/firebase/functions
> firebase emulators:exec --only firestore --project sample 'jest --runInBand' "--watch"

error: unknown option '--watch'
npm ERR! Test failed.  See above for more details.

Is there any workaround besides adding a new entry to scripts?

RobC
  • 22,977
  • 20
  • 73
  • 80
Rodrigo
  • 135
  • 4
  • 45
  • 107
  • I want to pass `--watch` manually. Like this `npm test -- --watch` – Rodrigo Jan 29 '21 at 14:11
  • 1
    Does this answer your question? [Pass command line args to npm scripts in package.json](https://stackoverflow.com/questions/51388921/pass-command-line-args-to-npm-scripts-in-package-json) – RobC Jan 29 '21 at 15:13
  • 1
    f you're running on *nix you can configure your npm script to utilize a shell function as follows: `"test": "func() { firebase emulators:exec --only firestore --project sample \"jest --runInBand $1\"; }; func"` - then run npm `test -- --watch`. You may instead need to further escape the double quotes, E.g. ``"test": "func() { firebase emulators:exec --only firestore --project sample \\\"jest --runInBand $1\\\"; }; func"`` Refer to link in previous comment for explanation and alternative node.js solution for cross-platform. – RobC Jan 29 '21 at 15:29

0 Answers0