The Wayback Machine - https://web.archive.org/web/20201009040627/https://github.com/vuejs/vue-jest/pull/263
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

Add coverage tool #263

Open
wants to merge 6 commits into
base: next
from
Open

Add coverage tool #263

wants to merge 6 commits into from

Conversation

@vvanpo
Copy link
Contributor

@vvanpo vvanpo commented Aug 2, 2020

See the coverage report by running yarn test:e2e && yarn coverage. If you're on macOS, your browser should open automatically with the report. If you're on Linux, you'll have to open the coverage/index.html manually.

I was having a hard time picturing just what our test coverage was through our custom testrunner, so I set out to add support for automated coverage collection.

Because the testrunner runs a separate Jest process inside each test subpackage, and because Jest cannot be configured to collect coverage outside the package it is running in, I had to add nyc (Istanbul's CLI) and proxy the call to Jest through it. Then I needed to use Istanbul's API to merge the resulting coverage reports into a single summary.

I removed most of the dependencies (including Jest itself) from the test subpackages, because there is not much reason to duplicate these as node module resolution has no problem finding them in the root package, and the test suites are an order of magnitude faster this way. I'm tempted to just remove all dependencies from each subpackage and just install them on the root instead, then we could eliminate the yarn install step altogether if we wanted. If we for some reason need to test specific dependency versions differently between test suites, we can always add dependencies back in, and this also helps us be very explicit in that circumstance.

The only difference in test behaviour now that we're resolving most dependencies from the root node_modules is that these dependencies are now locked in the lockfile (they were before too, but that was because we were erroneously removing yarn-lock.json instead of yarn.lock; I've fixed that in this PR). This helps us have more deterministic builds, but if we don't actually want that and want to always test the latest version of each package it's simple enough to remove the lockfile and run yarn install --no-lockfile in CI.

Screen Shot 2020-08-01 at 7 56 34 PM

vvanpo added 5 commits Jul 27, 2020
Cherry-picked changes from 22122c4, but
only for `test-runner.js`.
The lockfile was mispelled as `yarn-lock.json`, when `yarn` actually
uses `yarn.lock` files. We can just ignore them altogether with the
`--no-lockfile` flag.
Somewhere around @babel/*@7.8 are some weird module resolution bugs that
was giving me odd errors. Upgrading fixes these.

We can remove a number of dependencies from each test package, to allow
module resolution to find the common dependencies in the root package.
By removing dependencies that already exist in the root package, we can
greatly increase the speed of each test suite as `yarn install` has far
less work to do.
Because the testrunner runs Jest separately for each subpackage, and
because Jest cannot be configured to look outside of the package it is
running in, we need to use `nyc` (Istanbul's CLI).
@vvanpo vvanpo force-pushed the vvanpo:add-coverage branch from 020467d to ef416e4 Aug 2, 2020
@lmiller1990
Copy link
Member

@lmiller1990 lmiller1990 commented Aug 11, 2020

Wow, awesome! Sorry I just saw this. Please give me few days to review. I am not sure if there is a specific reason we have multiple projects with their own package.json files - I just joined this repo relatively recently, and am just trying to get everything back on track. I like these changes and anything that makes the repo more reliable and maintainable.

@lmiller1990
Copy link
Member

@lmiller1990 lmiller1990 commented Sep 5, 2020

I am sorry - I completely forgot about this. I will try to review asap.

@lmiller1990
Copy link
Member

@lmiller1990 lmiller1990 commented Sep 10, 2020

This looks fine. Can you rebase? Sorry it took me a long time to get to this! I really appreciate your contribution.

If you are excited about Vue jest I could really use some help on 5.0.0 for Vue 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.