Published at
Updated at
Reading time
1min
This post is part of my Today I learned series in which I share all my web development learnings.

You probably know that you can spin up Playwright's UI mode with npx playwright test --ui and rerun your tests with the watch mode.

Playwright UI mode with an arrow highlighting the button to turn on watch mode.

It's a handy feature when you're developing your tests while still being in the try-and-error phase. Especially when I'm working on quick tests, I miss the quick feedback loop of CLI watch mode, which doesn't seem to be implemented. Or is it?

I just discovered a CLI watch mode topic GitHub issue.

[Feature] "Headless" CLI Watch Mode
RichiCoder1 opened it Mar 24 2023

Turns out, people are asking for a CLI watch mode, and a first version is implemented, and you can use it by setting an environment variable.

PWTEST_WATCH=1 npx playwright test

I played around with it for a minute and will definitely use the hack out of it.

Demo session showing Playwright's experimental CLI watch mode.

But be aware: the current implementation is experimental, and it's there to gather feedback from the community. The feature might break or even disappear, but if you have feedback or want to give a thumbs-up, head over to the GitHub issue.

I'd love to see this becoming a real --watch mode, though.

If you enjoyed this article...

Join 5.6k readers and learn something new every week with Web Weekly.

Web Weekly — Your friendly Web Dev newsletter
Reply to this post and share your thoughts via good old email.
Stefan standing in the park in front of a green background

About Stefan Judis

Frontend nerd with over ten years of experience, freelance dev, "Today I Learned" blogger, conference speaker, and Open Source maintainer.

Related Topics