Rayrun
โ† Back to Discord Forum

Code coverage tools that actually determine Playwright coverage?

dirvinautomation_16636posted in #help-playwright
Open in Discord
dirvinautomation_16636

I seem to be a little confused, and I haven't found anything that could clarify..

I've worked with code coverage tools before, but only for Jest tests (and other "unit" style test libs). These work because they check every line of app code, and look for a corresponding line in test code. Playwright does not work the same way...

Is my understanding that this tool is merely a wrapper to allow playwright to analyze JS tests (not playwright tests) through the browser? You feed in your own coverage tool, and playwright plugs the scripts executed on the page into the provided coverage tool. Am I wrong?

That also brings up other tools like playwright-test-coverage which promise to give you a playwright coverage report, but for the life of me I can't understand how... It seems to me like you need a playwright test that covers everything in one go to get accurate results. This readme and this blog post do nothing to answer the questions I have, so I was hoping others here may insight on automating playwright coverage.

My understanding is that it's really not (pragmatically) possible. If I'm wrong, then I can explore for myself to how to make it work, but as it is, I don't want to sink a ton of time into a lost cause.

I'd love to hear about any and all tools folks have to used to measure playwright coverage as well ๐Ÿ™‚

This thread is trying to answer question "How do code coverage tools work with Playwright tests, and is it possible to obtain accurate coverage reports for Playwright?"

4 replies
dirvinautomation_16636

Bumping this for visibility. I'd love to hear what people think.

refactoreric

Hi, I haven't yet tried gathering code coverage with @playwright/test. From what I see in the docs, so far, the test runner itself has no support for it, but the library does, so you need to write some of your own plumbing or use something third party.

One of the Playwright developers did develop a demo here, as a community project: https://github.com/mxschmitt/playwright-test-coverage Maybe it's useful for you?

dirvinautomation_16636

Thanks Eric. I guess I was a little confused when reading these solutions that require a specific build tool, etc. because I couldn't tell if the end result was that the coverage report was specific to playwright coverage, or if they were using playwright to determine unit/component/integration coverage. I didn't want to dismantle the pipes without first getting some kind of confirmation. I wish mxschmidt would chime in here... I know they read the threads ๐Ÿ‘€

___kakashi___
___kakashi___

For future reference you can try to check out these guides:

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.