Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Unit Testing #27754

Open
MentalGear opened this issue Oct 23, 2023 · 4 comments
Open

[Feature] Unit Testing #27754

MentalGear opened this issue Oct 23, 2023 · 4 comments
Assignees
Labels
open-to-a-pull-request The feature request looks good, we are open to reviewing a PR

Comments

@MentalGear
Copy link

I have read about experimental component testing, but it would be great if we could use playwright also as a unit testing framework for singular functions, so no jest or vitest ist needed alongside. Is this currently already possible ?

@mxschmitt
Copy link
Member

This is already possible. You can use @playwright/test as of today for unit testing only. We use it e.g. here or here in such a kind of setup.

The golden rule is there then to just not use the page fixture and no browser gets launched and no browser dependencies need to be installed. Especially creating multiple projects or parameterising the tests is very useful for normal unit testing.

@yury-s
Copy link
Member

yury-s commented Oct 24, 2023

Closing per the response above, feel free to open a new issue if it doesn't work.

@yury-s yury-s closed this as completed Oct 24, 2023
@MentalGear
Copy link
Author

MentalGear commented Oct 24, 2023

Thank you for the detailed answer, @mxschmitt.
I would propose clarifying this in the docs, as it wasn't obvious to me when the full browser is being used and when not.

I'd suggest adding a new page "unit testing" to make it easy and clear to find for use-cases were only function tests are needed when using Playwright.

PS: ui mode is great, yet I wouldn't mind if watch mode were also available just as a cli.

@pavelfeldman
Copy link
Member

@MentalGear please feel free to send us a PR that updates the documentation!

@pavelfeldman pavelfeldman added open-to-a-pull-request The feature request looks good, we are open to reviewing a PR and removed v1.40 labels Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-to-a-pull-request The feature request looks good, we are open to reviewing a PR
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants