Open swensorm opened 4 years ago
For what its worth, this is a solution that works for my use case in executing npm scripts with and without start-server-and-test
Pass arguments to npm script using start-server-and-test
ARGS="--spec cypress/integration/login.spec.js --browser chrome" npm run test:open:local:dev
Pass arguments to npm script not using start-server-and-test
run test:live:dev -- --spec cypress/integration/login.spec.js --browser chrome
Requesting this as a feature to send arguments to the test command, without relying on npm or yarn directly. I came across this developing a bash script to run our UI regression tests within a Docker container using Storybook Storyshots and wanting to pass additional arguments, such as
--updateSnapshot
to the test command. The bash script sets up the container and runs a couple commands within it lastly being running the start-server-and-test command using npx.Attempts at passing the arguments:
npx start-server-and-test storybook http://localhost:9009 test:ui --updateSnapshot
expected <NPM script name that starts with server> <url or port> <NPM script name that runs tests>
npx start-server-and-test storybook http://localhost:9009 'test:ui --updateSnapshot'
/bin/sh: test:ui: command not found
npx start-server-and-test storybook http://localhost:9009 'test:ui -- --updateSnapshot'
/bin/sh: test:ui: command not found
Working solution in bash script:
Desired solution: