Why does a Playwright run with --project=admin-console --no-deps fail when the same command without the flag passes?
answer
- A flag that narrows what runs
- Something the graph would have done
- A promise the runner cannot verify
- Fine locally, dangerous in a pipeline
basics
~20 sBecause --no-deps tells Playwright to run only the named project and skip the projects it lists in dependencies, so whatever the setup project would have prepared is missing or stale and the tests break on the precondition.
solid answer
~40 s`--no-deps` runs the projects named by `--project` without the projects in their `dependencies` array. That is a promise you are making by hand: the preconditions are already satisfied. When they are not -- a first run on a clean machine, or state left over from an earlier and different run -- the tests fail on the missing precondition rather than on the behaviour they assert. The tell is that the failure is early, identical on every run, and disappears the moment the setup project is allowed to run again. Used well, the flag is a local iteration tool: run the setup project once, then loop on one project while editing a spec. Used in a pipeline it is a liability, because the run then depends on state no step in that pipeline produced.
code
bash · 2 linesnpx playwright test --project=console-setup
npx playwright test --project=admin-console --no-depsgo deeper
Know the flag means project dependencies, not packages, and that it makes the runner skip the setup project. Reach for it only when someone tells you the state is already prepared.
Explain the mechanism and the symptom: skipped preconditions produce an early, repeatable failure, unlike flakiness, and re-running the full graph is the diagnostic that confirms it.
Show the operational stance: keep the flag out of pipeline commands, make setup steps idempotent, and have projects fail fast with a message naming the precondition they need.
Decide when depending on externally prepared state is a legitimate design rather than a shortcut, and make sure whoever owns that state knows the suite depends on it.
## What the flag means `--no-deps` is a command-line switch for `playwright test`: it tells the runner to execute the projects you asked for and **not** the projects those list in their `dependencies` array. Without it, naming a project with `--project` also pulls in its whole dependency subgraph, which is normally what you want -- that is the point of declaring the dependency. With it, you are explicitly saying "the preconditions are already satisfied, do not redo them". ## Why the run then fails The failure is a missing precondition, not a broken test. A project that depends on a setup project is written on the assumption that the setup project just ran in this invocation. Skip it and whatever it was supposed to leave behind is either absent or left over from an earlier run: - The artefact the setup project writes to disk does not exist yet, so the first test that reads it throws during setup rather than failing an assertion. - The artefact exists but is stale, so tests fail in confusing, partial ways instead of failing at once. - The environment the setup project shapes -- feature flags on the internal admin console, a seeded staff role, an enabled module -- is in whatever state the last run left it in. The tell is that the failure moves: with `--no-deps` the suite breaks early and identically on every run, and adding the setup project back makes it green without touching any test code. ## When using it is correct 1. **Tight local iteration.** Run the setup project once, then loop on one test project with `--no-deps` while you edit a spec. Each iteration saves the entire preparation phase. 2. **A precondition owned outside the run.** If a pipeline stage or a shared environment already prepared what the suite needs, re-running the setup project would only duplicate it. 3. **Debugging the split itself** -- proving which state a project actually depends on by removing the step that provides it and watching what breaks. ## When it is a trap - **In CI.** A pipeline that runs projects with `--no-deps` to save time is depending on state left by a previous, unrelated run. It passes until the runner is replaced or a job runs on a clean machine. - **After changing the setup project.** The change simply does not take effect, and you debug the wrong file. - **As a fix for a slow suite.** The preparation phase is slow for a reason; hiding it makes runs unreproducible instead of faster. ## How to keep the escape hatch honest | Habit | Effect | |---|---| | Make setup steps idempotent | Re-running the graph is cheap, so `--no-deps` is a convenience, never a necessity | | Fail fast on missing precondition state | The error names what is missing instead of surfacing as a strange assertion failure | | Keep `--no-deps` out of pipeline commands | CI always executes the full graph and stays reproducible | | Split one setup project into narrow ones | Each project waits only for what it lists, so the full graph is fast enough to keep running | The flag is a local speed tool built on a promise you are making by hand. Playwright cannot verify the promise, which is why the same command is excellent at a developer's keyboard and a liability in a pipeline. ## Telling it apart from real flakiness The two failure shapes look similar in a terminal and are easy to confuse, so compare them deliberately: - A skipped precondition fails on **every** run, at the **same** point, and usually during a setup step rather than inside an assertion. - Genuine flakiness fails intermittently, at varying points, and often passes on retry. - The decisive experiment is one command: re-run without `--no-deps`. Green means the precondition was the cause and no test code needs changing.
- How would you make this failure mode obvious instead of confusing for the next engineer?Have the dependent project check its precondition up front and fail with a message naming what is missing and which project produces it, instead of letting a test throw deep inside a step. Making setup steps idempotent helps too, since re-running the full graph then costs little and `--no-deps` stays a convenience rather than a necessity.
saying these in an interview costs you the question
- Thinks --no-deps skips installing npm dependencies
- Believes it merely defers the setup project until later
- Uses it in CI to shorten the pipeline
- Assumes Playwright verifies the precondition is already met
- Blames flakiness for a failure that is deterministic