Open TurekBot opened 6 months ago
I did find that if I offer a second --
, it works as I hoped it would—but is that the way? Or is there a better approach?
npm test -- -- spec/recording_items.spec.ts
> serenity-js-playwright-test-template@3.0.0 test
> failsafe clean test:execute [...] test:report -- spec/recording_items.spec.ts
[clean]
[clean] > serenity-js-playwright-test-template@3.0.0 clean
[clean] > rimraf playwright-report target
[clean]
[failsafe] Script 'clean' exited with code 0
[test:execute]
[test:execute] > serenity-js-playwright-test-template@3.0.0 test:execute
[test:execute] > playwright test spec/recording_items.spec.ts
[test:execute]
[test:execute]
[test:execute] Running 12 tests using 5 workers
[5/12] [chromium] › recording_items.spec.ts:83:37 › Recording items › Todo List App › should show #main and #footer sections only when list contains items › Alice starts with
[5/12] [chromium] › recording_items.spec.ts:9:18 › Recording items › Todo List App › should show #main and #footer sections only when list contains items › Alice starts with
[5/12] [chromium] › recording_items.spec.ts:61:37 › Recording
@jan-molak, do you know if using a second --
is the only way, or are there other options?
Hey @TurekBot, I believe using the double separator --
is the only option, given how NPM works.
When your NPM script is defined as follows:
"test": "failsafe clean test:execute [...] test:report",
Running npm test -- tests/todo-page.spec.ts
makes NPM append tests/todo-page.spec.ts
to the original script command, which then becomes equivalent to:
"test": "failsafe clean test:execute [...] test:report tests/todo-page.spec.ts",
This makes Failsafe "think" that tests/todo-page.spec.ts
is another script you want to execute as part of your chain, rather than a positional argument as you intended.
However, if you run npm test -- -- tests/todo-page.spec.ts
, it will make NPM append -- tests/todo-page.spec.ts
to the original script command, which then becomes:
"test": "failsafe clean test:execute [...] test:report -- tests/todo-page.spec.ts",
... and now tests/todo-page.spec.ts
is passed correctly.
Having said that, maybe @muhqu has some idea how we could support this behaviour?
If I want to pass my script a flagless argument (help me out with a better phrase if there is one), how do I do that?
For example, Playwright takes folders or files as a flagless argument:
npx playwright test tests/todo-page.spec.ts
I tried
npm test -- spec/recording_items.spec.ts
But it still ran all the tests
How would you recommend I approach a situation like this?