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

refactor(coverage): remove unnecessary __vite_ssr_exports__ manipulation #7132

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Dec 26, 2024

Description

Vite SSR doesn't create a mapping for Object.defineProperty(__vite_ssr_exports__, ...) (as they are simply injected by MagicString.appendLeft), so I'm not sure what this replacement on v8 coverage is for.

It looks like test/coverage-test is passing locally. Let me check others on CI.

Sadly, this doesn't seem to entirely help #7130. There's still some odd changes (namely export getter get appears in function coverage) in #7096 after applying the same patch.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • Run the tests with pnpm test:ci.

Documentation

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs command.

Changesets

  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.

Copy link

netlify bot commented Dec 26, 2024

Deploy Preview for vitest-dev ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit cd186af
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/676ca2d8bf75700008330cc9
😎 Deploy Preview https://deploy-preview-7132--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@hi-ogawa
Copy link
Contributor Author

/ecosystem-ci run

@vitest-ecosystem-ci
Copy link

vitest-ecosystem-ci bot commented Dec 26, 2024

📝 Ran ecosystem CI: Open

suite result
aria-live-capture ✅ success
nuxt ❌ failure
nuxt-test-utils ❌ failure
elk ✅ success
effect ❌ failure
lerna-lite ✅ success
zustand ✅ success
vue ✅ success
vite ✅ success
vitest-vscode ❌ failure
vitest-sonar-reporter ❌ failure
vitest-github-actions-reporter ❌ failure
vitest-browser-simple ✅ success
vitest-browser-examples ❌ failure
vitest-coverage-large ✅ success
vitest-reporters-large ✅ success
vitest-benchmark-large ✅ success

@hi-ogawa hi-ogawa marked this pull request as ready for review December 26, 2024 00:48
Copy link
Member

@AriPerkkio AriPerkkio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add test case that validates function counts. We used to have one but looks like it got removed during some test setup refactorings.

So maybe something like:

test('function count is correct', async () => {
const coverageJson = await readCoverageJson()
const coverageMap = libCoverage.createCoverageMap(coverageJson as any)
const fileCoverage = coverageMap.fileCoverageFor('<process-cwd>/src/function-count.ts')
const { functions } = fileCoverage.toSummary()
expect(functions.total).toBe(5)
expect(functions.covered).toBe(3)
})

/*
* This file should have:
* - 5 functions in total
* - 3 covered functions
* - 2 uncovered functions
*/
/* eslint-disable unused-imports/no-unused-vars */
// This function is covered
function first() {
return 1
}
first()
// This function is covered
export function second() {
fifth()
return 2
}
// This function is NOT covered
export function third() {
throw new Error('Do not call this function')
}
// This function is NOT covered
function fourth() {
return 4
}
// This function is covered
function fifth() {
return 5
}

@hi-ogawa
Copy link
Contributor Author

We should add test case that validates function counts.

It looks like there are several tests related to function count like this snapshot

"fnMap": {
"0": {
"name": "isEven",

In #7096, I'm seeing get gets included in the snapshot, so there's something wrong, but in this PR, that's not happening.

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

Successfully merging this pull request may close these issues.

2 participants