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

How to allow user input from CLI? #380

Closed grantspilsbury closed 6 months ago

grantspilsbury commented 6 months ago

I am using Percy and Cypress to run visual tests on my Nextjs app.

To run a single spec I add this to the script of my package.json eg

    "scripts": {
        "test-visual:single": "start-server-and-test 'npm run dev' http://localhost:3000 'percy exec -- cypress run --spec /path/to/test.cy.ts'",
      },

I want the user to enter the path of the test spec (/path/to/test.cy.ts). What's the right way to do this?

I have tried to use $PATH

$PATH=/path/to/test.cy.ts npm run test-visual:single

"test-visual:single": "start-server-and-test 'npm run dev' http://localhost:3000 'percy exec -- cypress run --spec $PATH'",

I have also tried: npm run test-visual:single /path/to/test.cy.ts

    "scripts": {
        "test-visual:single": "start-server-and-test 'npm run dev' http://localhost:3000 'percy exec -- cypress run --spec $1'",
      },

with no luck

MikeMcC399 commented 6 months ago

@grantspilsbury

I guess you solved this yourself!? There is an active technical user community on Discord for Cypress

Discord chat (click on button)

if you need any help in future about Cypress "how-to" issues.

grantspilsbury commented 6 months ago

@grantspilsbury

I guess you solved this yourself!? There is an active technical user community on Discord for Cypress

Discord chat (click on button)

if you need any help in future about Cypress "how-to" issues.

Thanks Mike. I figured it wasn't really a start-server-and-test issue so I closed it