Pass flags/arguments to command for internal command, for example to scripts in npm or yarn
So, let’s say you need to add new flag --watch to your script from package.json In this case to “test” script
"scripts": {
"test": "jest"
}
Yes, you can add "test": "jest --watch" to your package.json, but that might be not very convinient, insted you can add this directly in terminal.
But mind, that
$ npm test --watch
won’t work as expected because --watch will be considered as a part of npm command, not jest comman as we would like
So, what you should do instead is
$ npm test -- --watch
First pair of -- associates arguments with npm (in our case we don’t need any) and second pair of -- will associate with test command (which is in our case is jest)
Hope you find this info helpful ;)