I'm just getting started with Playwright but I'm getting confused between the cli commands used to run tests, e.g. npx playwright test and commands that you add to your package.json, for example...
{
"scripts": {
"pretest": "tsc --incremental -p tests/tsconfig.json",
"test": "playwright test -c tests-out"
}
}
I'm aware that I can run npm test here, but why does this work within a script but not when I simply run playwright test -c tests-out in the terminal? I just get Unknown command: "playwright".
What is the association between the npx playwright test command and playwright test?
Also why does -c refer to an output directory here yet for npx playwright test this refers to a configuration file?
The reason I ask is that in a typescript Playwright project I am working on the following scripts are defined...
"e2e-playwright-build": "cd apps/playwright-e2e && tsc",
"e2e-playwright": "npm run e2e-playwright-build && cd apps/playwright-e2e/src/tests && playwright test -c tests-out --config=../../tests-out/apps/playwright-e2e/src/tests/configs/playwright.config.js --grep-invert \"@example|@visual|@access|@failfast\"",
These commands are too broad for my requirements and I would like to run specific tests based on my own commands, however whenever I try to run npx playwright test I just get...
Unexpected current working directory - C:\Tribal\tribal.edge.ui\module\tribal.edge.ui\apps\playwright-e2e\tests-out
With a bunch of other errors. My folder structure looks like the following...
├── apps
│ ├── playwright-e2e
│ ├── src
├── node_modules
├── package.json
├── package-lock.json
└── .gitignore
