garris / BackstopJS

Catch CSS curve balls.
http://backstopjs.org
MIT License
6.69k stars 604 forks source link

Can't use --filter with js object+npm run script #1415

Closed celestina01 closed 2 years ago

celestina01 commented 2 years ago

Hi Garris, thanks for the awesome tool. When I put my config and scenarios in the default backstop.json, I can use --filter="example" to run specific scenarios. I am trying to use a js object for my config and tests and would like to eventually separate the tests into different files. I can run the tests but I can's use --filter in the cli. Here is my package.json:

"test:bs": "backstop test --configPath=backstop-tests/all-tests.js",
 "test:bs:reference": "backstop reference --configPath=backstop-tests/all-tests.js",
 "test:bs:approve": "backstop approve --configPath=backstop-tests/all-tests.js",

If I run ...

npm run test:bs --filter="autotip"

...it will run all the tests, not just autotip.

Interesting though, if I add the filter to the run script...

"test:bs": "backstop test --configPath=backstop-tests/all-tests.js --filter='autotip'"

... it works.

Can you help me figure out what is going on here, please?

masi commented 2 years ago

With npm you have to use an extra -- to separate npm arguments from the arguments of the command:

npm run test:bs -- --filter="autotip"

celestina01 commented 2 years ago

Thank you!