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

Code coverage for JavaScript tests #2505

Open
mgeisler opened this issue Dec 6, 2024 · 2 comments
Open

Code coverage for JavaScript tests #2505

mgeisler opened this issue Dec 6, 2024 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@mgeisler
Copy link
Collaborator

mgeisler commented Dec 6, 2024

Now that #2462 is fixed, a natural next step would be to add support for code coverage on the JavaScript tests. Basically, I would like to know that we exercise most or all of book.js in our tests. The same goes for the other JavaScript files we maintain.

@Alx-Lai, @michael-kerscher or someone else, please let me know if you're interested in this.

@mgeisler mgeisler added enhancement New feature or request good first issue Good for newcomers labels Dec 6, 2024
@michael-kerscher
Copy link
Collaborator

I'm not sure if this is a major blocker but I wanted to document this at least.

We use the local runner

runner: "local",

and we use the browser api to let the local runner test properties in the remote browser. Example:

await browser.url("/");
expect(await browser.execute(() => window.default_theme)).toBe("light");

I found documentation for coverage support for wdio but this documents how a browserrunner needs to be configured.

In order to enable code coverage reporting, enable it through the WebdriverIO browser runner configuration, e.g.:

This page also only documents Coverage Options for the browser runner

@michael-kerscher
Copy link
Collaborator

I'm not sure how to use the browser runner as this seems to requires a vite setup, which seems non-trivial for our use case. As far as I currently understand, vite needs to serve the entire html book + javascript and the tests will not run "outside" the served html but are injected into this site.

My current setup is looking at the website from the outside via the webdriver protocol with a browser that has this page open. The test is not running in the browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants