bahmutov / start-server-and-test

Starts server, waits for URL, then runs test command; when the tests end, shuts down server
MIT License
1.53k stars 95 forks source link

Pass Arguments To Test Command #267

Open swensorm opened 4 years ago

swensorm commented 4 years ago

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:

Working solution in bash script:

#!/bin/bash
npx start-server-and-test storybook http://localhost:9009 "npm run test:ui -- $@"

Desired solution:

#!/bin/bash
npx start-server-and-test storybook http://localhost:9009 "test:ui -- $@"
# or
npx start-server-and-test storybook http://localhost:9009 test:ui $@
coltdorsey commented 2 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

image

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