playwright
playwright copied to clipboard
[Feature] UI mode doesn't respect test dependencies
Running playwright test with a test that have a dependency. For example the below snippet will run the setup
dependency when running npx playwright test
. In UI mode I would reasonably expect the same - in that when running a test that has a dependency it would run the dependency first and then run the test. This is currently not the case.
name: 'loggedIn',
use: {
...devices['Desktop Chrome'],
storageState: STORAGE_STATE,
},
testIgnore: ['**/*login.spec.ts', '**/*.setup.ts'],
dependencies: ['setup'],
},```
This is by design. We assume that you manually run your 'setup' project once and then repeatedly run your test project, while reusing the login credentials. We can make it configurable though, so I'll leave it open to collect the feedback.
I think we should at least take dependencies into account while using Run all
button. In this case I would expect they would run in defined order.
For watch mode, I agree with the design. It should be manual.
Or maybe there should be a button Run with dependencies
or a checkbox?
I personally don't think it's intuitive to manually have to run the dependencies. I'm also not clear on the reasoning why there would be different expectations for playwright test tests/<spec>
and playwright test --ui
and selecting a test that has dependencies. Is there particular use cases here you're thinking about?
Agree at the least a config option would be useful but I think it's worth hearing from others.
Thanks for your awesome work on this as always!
If I run a specific test (just one using a tag) having dependency in my project on auth.setup.ts it runs fine and console logs say running 2 tests (one auth setup and the other my dependant test).
I expect similar behaviour in the UI Mode (with flag --ui). The test defined in auth.setup.ts does not even appear in the UI Mode to run explicitly even if I want to.
If I run a specific test (just one using a tag) having dependency in my project on auth.setup.ts it runs fine and console logs say running 2 tests (one auth setup and the other my dependant test).
I expect similar behaviour in the UI Mode (with flag --ui). The test defined in auth.setup.ts does not even appear in the UI Mode to run explicitly even if I want to.
I would also expect this behaviour
I expect similar behaviour in the UI Mode (with flag --ui). The test defined in auth.setup.ts does not even appear in the UI Mode to run explicitly even if I want to.
Is there any way to run the test defined in auth.setup.ts in the UI?
I find it confusing since dependencies are run when I use the VS Code Playwright extension to run individual tests. Although I understand that this is intentional, it would be helpful to have the ability to choose whether to run them or not.
Both v1.33 and v1.34 labels were removed from this issue. Are we targeting this in some later release now?
Any update on this feature ? I have made code changes in Prod to use dependencies and I would like to use the UI feature to develop the code.
I agree with the comments above - If you are using a project that has dependencies ie Setup , then these would either need to be included in the --ui running of the tests or as mentioned a tickbox to include/exclude - My setup tests are required for the actual tests to run and so currently unable to use the feature which is a shame because it looks amazing
The biggest disadvantage of not handling project dependencies in UI mode are:
- inconsistency: runner vs UI mode. Behavior when triggering i.e. single test is different.
- remembering how my dependencies are structured to be able use UI mode.
New user can be confused and wasting lot of time figuring out why tests works in one tool and fail in other.
I always need to run the setup dependency first. My setup routine deletes data from previous runs so that the test user's account is in a clean state before the test(s) run. If this doesn't happen, many of my tests fail as they don't find the expected state.
That said, I can see that not all users would want/need their dependencies to run first. Having a checkbox option in UI mode to choose whether dependencies run or not would be ideal then everyone can use it in their preferred way.
@sarah-gelt you can try the new project teardown feature :) Not a solution to this issue, but might help with productivity.
@sarah-gelt you can try the new project teardown feature :) Not a solution to this issue, but might help with productivity.
I already have, thanks. We used to run setup and teardown using the old method, but switched to setup-only using project dependencies as the benefits of running it as a project outweighed the lack of teardown for us. Now teardown can be done as a project dependency as well, we are running it at both ends again.
To add to this: global setup and teardown also don't run in the UI, which is a requirement for some of us that do things like DB seeding. It would be good to be able to (selectively) run those as well.
Certainly globalSetup should run because it's, well, a global setup :)
In my case, it seems that the project dependent is running, but there is no indication in the UI mode for it. even not in the 'Toggle output' part
Would really love if this could be changed! I understand the idea that we should manually run our setup so that it only runs once, but as a new user of Playwright, I just wasted half a day trying to figure out what I was doing wrong and why my global setup dependency wasn't running first. Following this tutorial for how to create a global setup, there is zero mention of this. At the very least it should be documented.
Got bit by this today. I don't use VSCode. Playwright only became viable for me when UI mode was introduced. As mentioned in earlier comments, the discrepancies between UI mode and the runner mode can be very confusing.
I don't really understand the design choice but would suggest a flag for the cli like --with-deps
.
Atm this is a blocker for non VSCode users.
It would be very good if this was configurable.
Thank you!
I would love this to be configurable as well.
Same. Having the dependencies run in UI mode by default is very much an expected behaviour. For those who don't need it, you could keep the flag to avoid running deps.
There are more comments than upvotes, if you wish that capability to get considered, please upvote (thumbs up icon) on the first post
This has cost my several hours - I would never have expected that UI runs completely different from console.