-
Notifications
You must be signed in to change notification settings - Fork 1
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
Compatibility with Vitest browser mode #8
Comments
Technically speaking, it requires that Vitest browser can support the collection of coverage, for example, by using the coverage API in playwright test fixtures. I currently don't know how to support it and will look into it. Could you please provide a example repo for the Vitest browser mode test? |
Thanks for the quick response. I have tried to get it working using the Playwright config within Vitests config (via https://github.com/chapmanio/monocart-vitest-browser-coverage is a quick example repo to try against - it's got a (rubbish) example of a Playwright end to end tests (with coverage), Vitest unit test (with coverage) and Vitest browser test (with failing coverage) Let me know if there is anything else I can do to help. |
I've just seen Vitest 3 in now out (https://vitest.dev/blog/vitest-3) which includes some changes and better docs for using Playwright in browser-mode (https://vitest.dev/guide/browser/playwright.html). I'm not sure if this will help or not, the |
Could you please try vitest-monocart-coverage@3.0.0
export default defineConfig({
test: {
include: ['test/*.test.js'],
coverage: {
enabled: true,
include: ['src/**'],
provider: 'custom',
customProviderModule: 'vitest-monocart-coverage/browser'
},
browser: {
enabled: true,
headless: true,
instances: [{
browser: 'chromium'
}],
provider: 'playwright'
}
}
}); |
I'm just waiting on vitest-dev/vitest#7308 to be resolved so I can test this. However, I'm not sure this will work if you have both unit tests (normal vitest) and browser tests in the same project as coverage is defined for the whole workspace https://vitest.dev/guide/workspace. I haven't found a way (yet) to define different coverage per workspace. |
I create a issue for it |
I've been using monocart coverage for a while but I can't get it working with Vitest in browser mode.
https://vitest.dev/guide/browser/ using Typescript/React/Playwright/Chromium as the options via:
The tests run and pass/fail as expected, but after they complete I get this error:
Is there anything I can do to support this?
I have monocart coverage working with Playwright end to end tests (and component tests) from your other excellent examples. As I have Vitest browser mode set up with Playwright I was wondering if I could use the same approach to track coverage, but as Vitest browser isn't using the playwright fixtures I wasn't sure how.
I've also been looking at https://github.com/cenfun/monocart-coverage-reports?tab=readme-ov-file#collecting-v8-coverage-data but again I'm not sure how to get this working with this package.
The text was updated successfully, but these errors were encountered: